ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-09-09 16:28:02
Exec Total Coverage
Lines: 9574 13207 72.5%
Functions: 114 144 79.2%
Branches: 7274 12325 59.0%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 429 std::map<int32_t, script_slot_data > ffcmap;
92 429 std::map<int32_t, script_slot_data > globalmap;
93 429 std::map<int32_t, script_slot_data > genericmap;
94 429 std::map<int32_t, script_slot_data > itemmap;
95 429 std::map<int32_t, script_slot_data > npcmap;
96 429 std::map<int32_t, script_slot_data > ewpnmap;
97 429 std::map<int32_t, script_slot_data > lwpnmap;
98 429 std::map<int32_t, script_slot_data > playermap;
99 429 std::map<int32_t, script_slot_data > dmapmap;
100 429 std::map<int32_t, script_slot_data > screenmap;
101 429 std::map<int32_t, script_slot_data > itemspritemap;
102 429 std::map<int32_t, script_slot_data > comboscriptmap;
103 429 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14586 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14586 return p_igetw(&unused, f);
121 }
122
123 21996 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 21989 times.
21996 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 7 output = fmt::format("{} --{}", slotname, scriptname);
129 7 break;
130 21989 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21989 output = fmt::format("{} {}", slotname, scriptname);
133 21989 }
134 21996 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 804 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 804 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 484 times.
804 if (unencrypted_result.decoded_pf)
721 320 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 484 times.
484 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 484 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 484 bool compressed = unencrypted_result.compressed;
737 484 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 484 temp_name(tmpfilename);
741 char percent_done[30];
742 484 int32_t current_method=0;
743
744 PACKFILE *f;
745 484 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 484 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(strcmp(filename, "default.qst")!=0)
752 {
753 484 box_out(filename);
754 484 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 484 box_out("...");
760 484 box_eol();
761 484 box_eol();
762
763
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(encrypted)
764 {
765 484 box_out("Decrypting...");
766 484 box_save_x();
767 484 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 63 times.
484 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 484 box_out("okay.");
833 484 box_eol();
834 484 }
835 else
836 {
837 oldquest = true;
838 }
839
840 484 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 484 times.
484 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 484 times.
484 if(!oldquest)
864 {
865 484 delete_file(tmpfilename);
866 484 }
867
868 484 box_out("okay.");
869 484 box_eol();
870
871 484 return f;
872 804 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readtunes(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 804 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 198 times.
804 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 606 guys.setMax(255);
1132 606 items.setMax(255);
1133 606 Ewpns.setMax(255);
1134 606 Lwpns.setMax(255);
1135 606 chainlinks.setMax(255);
1136 606 decorations.setMax(255);
1137 606 particles.setMax(255);
1138 606 }
1139 else
1140 {
1141 198 guys.setMax(255);
1142 198 items.setMax(255);
1143 198 Ewpns.setMax(255);
1144 198 Lwpns.setMax(255);
1145 198 chainlinks.setMax(255);
1146 198 decorations.setMax(255);
1147 198 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 804 }
1150
1151 315 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 315 bool ret = true;
1154
1/2
✓ Branch 0 taken 315 times.
✗ Branch 1 not taken.
315 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 80640 times.
80955 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 315 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 940560 int32_t read_weap_data(weapon_data& data, PACKFILE* f)
1199 {
1200 word v_weapon_data;
1201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940560 times.
940560 if(!p_igetw(&v_weapon_data,f))
1202 return qe_invalid;
1203
1204
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetw(&(data.flags), f))
1205 return qe_invalid;
1206
1207
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.moveflags), f))
1208 return qe_invalid;
1209
1210
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetw(&(data.wflags), f))
1211 return qe_invalid;
1212
1213
2/2
✓ Branch 0 taken 4702800 times.
✓ Branch 1 taken 940560 times.
5643360 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
1214 {
1215
1/2
✓ Branch 0 taken 4702800 times.
✗ Branch 1 not taken.
4702800 if (!p_getc(&(data.burnsprs[q]), f))
1216 return qe_invalid;
1217
1/2
✓ Branch 0 taken 4702800 times.
✗ Branch 1 not taken.
4702800 if (!p_getc(&(data.light_rads[q]), f))
1218 return qe_invalid;
1219 4702800 }
1220
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.glow_shape), f))
1221 return qe_invalid;
1222
1223
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.override_flags), f))
1224 return qe_invalid;
1225
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.tilew), f))
1226 return qe_invalid;
1227
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.tileh), f))
1228 return qe_invalid;
1229
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hxsz), f))
1230 return qe_invalid;
1231
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hysz), f))
1232 return qe_invalid;
1233
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hzsz), f))
1234 return qe_invalid;
1235
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hxofs), f))
1236 return qe_invalid;
1237
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hyofs), f))
1238 return qe_invalid;
1239
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.xofs), f))
1240 return qe_invalid;
1241
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.yofs), f))
1242 return qe_invalid;
1243
1244
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetzf(&(data.step), f))
1245 return qe_invalid;
1246
1247
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.unblockable), f))
1248 return qe_invalid;
1249
1250
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.timeout), f))
1251 return qe_invalid;
1252
1253
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.imitate_weapon), f))
1254 return qe_invalid;
1255
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.default_defense), f))
1256 return qe_invalid;
1257
1258
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.lift_level), f))
1259 return qe_invalid;
1260
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.lift_time), f))
1261 return qe_invalid;
1262
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetzf(&(data.lift_height), f))
1263 return qe_invalid;
1264
1265
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if(!p_igetw(&(data.script), f))
1266 return qe_invalid;
1267
2/2
✓ Branch 0 taken 7524480 times.
✓ Branch 1 taken 940560 times.
8465040 for(uint q = 0; q < 8; ++q)
1268
1/2
✓ Branch 0 taken 7524480 times.
✗ Branch 1 not taken.
7524480 if(!p_igetl(&(data.initd[q]), f))
1269 return qe_invalid;
1270
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if(!p_igetw(&(data.pierce_count), f))
1271 return qe_invalid;
1272 940560 return 0;
1273 940560 }
1274
1275 373 int32_t get_qst_buffers()
1276 {
1277 373 TheMaps.resize(MAPSCRS);
1278 373 old_combo_pages.resize(MAPSCRS);
1279 373 map_infos.resize(1);
1280
1281 373 Z_message("OK\n");
1282
1283 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1284 // (Shoelace's "Hero of Dreams" uses 1415.)
1285 // So let's be a bit generous and allow 4096 initially.
1286 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1287 // I tested it and it worked without flaw on 6/6/11. - L.
1288 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1289 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1290 // See https://discord.com/channels/876899628556091432/992984989073416242
1291 373 msg_strings_size = 8192;
1292
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 MsgStrings = new MsgStr[msg_strings_size];
1294
1295 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1296
2/2
✓ Branch 0 taken 3055616 times.
✓ Branch 1 taken 373 times.
3055989 for(auto q = 0; q < msg_strings_size; ++q)
1297 {
1298 3055616 MsgStrings[q].clear();
1299 3055616 }
1300
1301
4/6
✓ Branch 0 taken 190976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190603 times.
✓ Branch 3 taken 373 times.
✓ Branch 4 taken 373 times.
✗ Branch 5 not taken.
190976 if((DMaps=new dmap[MAXDMAPS])==NULL)
1302 return 0;
1303
1304
1305
1306 373 combobuf.clear();
1307 373 combobuf.resize(MAXCOMBOS);
1308
1309
1310
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1311 return 0;
1312
1313 373 free_newtilebuf();
1314
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1315 return 0;
1316
1317 373 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1318 //Z_message("Performed memset on tiles\n");
1319 373 clear_tiles(newtilebuf);
1320 //Z_message("Performed clear_tiles()\n");
1321
1322
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 13 times.
373 if (get_app_id() == App::zquest)
1323 {
1324
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1325 return 0;
1326
1327 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1328 13 clear_tiles(grabtilebuf);
1329 13 }
1330
1331
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((trashbuf=(byte*)malloc(100000))==NULL)
1332 return 0;
1333
1334 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1335 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1336 // fixed by ensuring there's actually itemdata there.
1337 // If you change this, be sure to update del_qst_buffers, too.
1338
1339
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1340 return 0;
1341
1342
2/2
✓ Branch 0 taken 95861 times.
✓ Branch 1 taken 373 times.
96234 for(size_t q = 0; q < MAXITEMS+1; ++q)
1343 95861 itemsbuf[q].clear();
1344 373 itemsbuf++;
1345
1346
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1347 return 0;
1348
1349 373 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1350
1351
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1352 return 0;
1353
1354
2/2
✓ Branch 0 taken 190976 times.
✓ Branch 1 taken 373 times.
191349 for(size_t q = 0; q < MAXGUYS; ++q)
1355 190976 guysbuf[q].clear();
1356
1357
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 373 return 1;
1361 373 }
1362
1363
1364 699 void free_newtilebuf()
1365 {
1366
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 372 times.
699 if(newtilebuf)
1367 {
1368
2/2
✓ Branch 0 taken 70141500 times.
✓ Branch 1 taken 327 times.
70141827 for(int32_t i=0; i<NEWMAXTILES; i++)
1369
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 69927000 times.
140068500 if(newtilebuf[i].data)
1370 69927000 free(newtilebuf[i].data);
1371
1372 327 free(newtilebuf);
1373 327 newtilebuf = 0;
1374 327 }
1375 699 }
1376
1377 326 void free_grabtilebuf()
1378 {
1379
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 11 times.
326 if (get_app_id() == App::zquest)
1380 {
1381
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1382 {
1383
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1385
1386 11 free(grabtilebuf);
1387 11 grabtilebuf = 0;
1388 11 }
1389 11 }
1390 326 }
1391
1392 326 void del_qst_buffers()
1393 {
1394
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
326 if(MsgStrings) delete[] MsgStrings;
1395
1396
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
326 if (DMaps) delete[] DMaps;
1397
1398 326 combobuf.clear();
1399
1400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(colordata) free(colordata);
1401
1402 326 free_newtilebuf();
1403 326 free_grabtilebuf();
1404
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(trashbuf) free(trashbuf);
1406
1407 // See get_qst_buffers
1408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(itemsbuf)
1409 {
1410 326 itemsbuf--;
1411 326 free(itemsbuf);
1412 326 }
1413
1414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(wpnsbuf) free(wpnsbuf);
1415
1416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(guysbuf) free(guysbuf);
1417
1418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(combo_class_buf) free(combo_class_buf);
1419 326 }
1420
1421 18 bool init_palnames()
1422 {
1423 // if(palnames==NULL)
1424 // return false;
1425
1426
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1427 {
1428
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1429 {
1430 case 0:
1431 18 sprintf(palnames[x],"Overworld");
1432 18 break;
1433
1434 case 10:
1435 18 sprintf(palnames[x],"Caves");
1436 18 break;
1437
1438 case 11:
1439 18 sprintf(palnames[x],"Passageways");
1440 18 break;
1441
1442 default:
1443 9162 sprintf(palnames[x],"%c",0);
1444 9162 break;
1445 }
1446 9216 }
1447
1448 18 return true;
1449 }
1450
1451 99629 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1452 {
1453 void *p;
1454
1455
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 p = _AL_MALLOC(MAX(size, alloc_size));
1456
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99629 times.
99629 if(!p)
1458 {
1459 return NULL;
1460 }
1461
1462
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 if(!pfread(p,size,f))
1463 {
1464 _AL_FREE(p);
1465 return NULL;
1466 }
1467
1468
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 if(pack_ferror(f))
1469 {
1470 _AL_FREE(p);
1471 return NULL;
1472 }
1473
1474 99629 return p;
1475 99629 }
1476
1477 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1478 static const byte* legacy_skip_flags;
1479
1480 /* read_midi:
1481 * Reads MIDI data from a datafile (this is not the same thing as the
1482 * standard midi file format).
1483 */
1484
1485 10210 static MIDI *read_midi(PACKFILE *f)
1486 {
1487 MIDI *m;
1488 int32_t c;
1489 10210 int16_t divisions=0;
1490 10210 int32_t len=0;
1491
1492 10210 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1493
1494
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!m)
1495 {
1496 return NULL;
1497 }
1498
1499
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1500 {
1501 326720 m->track[c].len = 0;
1502 326720 m->track[c].data = NULL;
1503 326720 }
1504
1505 10210 p_mgetw(&divisions,f);
1506 10210 m->divisions=divisions;
1507
1508
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1509 {
1510 326720 p_mgetl(&len,f);
1511 326720 m->track[c].len=len;
1512
1513
2/2
✓ Branch 0 taken 227091 times.
✓ Branch 1 taken 99629 times.
326720 if(m->track[c].len > 0)
1514 {
1515 99629 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1516
1517
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 if(!m->track[c].data)
1518 {
1519 destroy_midi(m);
1520 return NULL;
1521 }
1522 99629 }
1523 326720 }
1524
1525 LOCK_DATA(m, sizeof(MIDI));
1526
1527
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1528 {
1529
2/2
✓ Branch 0 taken 99629 times.
✓ Branch 1 taken 227091 times.
326720 if(m->track[c].data)
1530 {
1531 LOCK_DATA(m->track[c].data, m->track[c].len);
1532 99629 }
1533 326720 }
1534
1535 10210 return m;
1536 10210 }
1537
1538 void clear_combo(int32_t i)
1539 {
1540 combobuf[i].clear();
1541 }
1542
1543 void clear_combos()
1544 {
1545 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1546 clear_combo(tmpcounter);
1547 }
1548
1549 void pack_combos()
1550 {
1551 int32_t di = 0;
1552
1553 for(int32_t si=0; si<1024; si+=2)
1554 combobuf[di++] = combobuf[si];
1555
1556 for(; di<1024; di++)
1557 clear_combo(di);
1558 }
1559
1560 480 void reset_tunes(zctune *tune)
1561 {
1562
2/2
✓ Branch 0 taken 120960 times.
✓ Branch 1 taken 480 times.
121440 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1563 {
1564 120960 tune[i].reset();
1565 120960 }
1566 480 }
1567
1568 int32_t doortranslations_u[9][4]=
1569 {
1570 {37,38,53,54},
1571 {37,38,39,40},
1572 {37,38,55,56},
1573 {37,38,39,40},
1574 {37,38,53,54},
1575 {37,38,53,54},
1576 {37,38,53,54},
1577 {7,8,23,24},
1578 {7,8,41,42}
1579 };
1580
1581 int32_t doortranslations_d[9][4]=
1582 {
1583 {117,118,133,134},
1584 {135,136,133,134},
1585 {119,120,133,134},
1586 {135,136,133,134},
1587 {117,118,133,134},
1588 {117,118,133,134},
1589 {117,118,133,134},
1590 {151,152,167,168},
1591 {137,138,167,168},
1592 };
1593
1594 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1595 int32_t doortranslations_l[9][6]=
1596 {
1597 {66,67,82,83,98,99},
1598 {66,68,82,84,98,100},
1599 {66,69,82,85,98,101},
1600 {66,68,82,84,98,100},
1601 {66,67,82,83,98,99},
1602 {66,67,82,83,98,99},
1603 {66,67,82,83,98,99},
1604 {64,65,80,81,96,97},
1605 {64,65,80,114,96,97},
1606 };
1607
1608 int32_t doortranslations_r[9][6]=
1609 {
1610
1611 {76,77,92,93,108,109},
1612 {75,77,91,93,107,109},
1613 {74,77,90,93,106,109},
1614 {75,77,91,93,107,109},
1615 {76,77,92,93,108,109},
1616 {76,77,92,93,108,109},
1617 {76,77,92,93,108,109},
1618 {78,79,94,95,110,111},
1619 {78,79,125,95,110,111},
1620 };
1621
1622 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1623 {
1624 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1625 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1626 }
1627
1628 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1629 {
1630 //these are here to bypass compiler warnings about unused arguments
1631 840750 map=map;
1632 840750 scr=scr;
1633 840750 pos=pos;
1634
1635 //what does this function do?
1636 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1637 840750 return 2;
1638 }
1639
1640 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1641 {
1642
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1643 {
1644 18423 return 0;
1645 }
1646
1647 4425 DoorComboSet tempdcs{};
1648
1649 //up
1650
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1651 {
1652
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1653 {
1654 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1655 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1656 159300 }
1657 39825 }
1658
1659 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1660 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1661 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1662 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1663 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1664 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1665
1666 //down
1667
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1668 {
1669
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1670 {
1671 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1672 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1673 159300 }
1674 39825 }
1675
1676 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1677
1678 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1679 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1680 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1681 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1682 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1683
1684 //left
1685 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1686
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1687 {
1688
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1689 {
1690 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1691 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1692 238950 }
1693 39825 }
1694
1695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1696 {
1697 if((j!=2)&&(j!=3))
1698 {
1699 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1700 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1701 }
1702 }
1703
1704 4425 tempdcs.bombdoorcombo_l[0]=0;
1705 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1706 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1707 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1708 4425 tempdcs.bombdoorcombo_l[2]=0;
1709 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1710 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1711 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1712
1713 //right
1714
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1715 {
1716
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1717 {
1718 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1719 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1720 238950 }
1721 39825 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1724 {
1725 if((j!=2)&&(j!=3))
1726 {
1727 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1728 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1729 }
1730 }
1731
1732 4425 tempdcs.bombdoorcombo_r[0]=0;
1733 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1734 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1735 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1736 4425 tempdcs.bombdoorcombo_r[2]=0;
1737 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1738 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1739 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1740
1741 int32_t k;
1742
1743
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1744 {
1745
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1746 {
1747 4365 break;
1748 }
1749 5941 }
1750
1751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1752 {
1753 return 0;
1754 }
1755
1756
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1757 {
1758 60 DoorComboSets[k]=tempdcs;
1759 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1760 60 ++door_combo_set_count;
1761 60 }
1762
1763 4425 return k;
1764 /*
1765 doorcombo_u[9][4];
1766 doorcset_u[9][4];
1767 doorcombo_d[9][4];
1768 doorcset_d[9][4];
1769 doorcombo_l[9][6];
1770 doorcset_l[9][6];
1771 doorcombo_r[9][6];
1772 doorcset_r[9][6];
1773 bombdoorcombo_u[2];
1774 bombdoorcset_u[2];
1775 bombdoorcombo_d[2];
1776 bombdoorcset_d[2];
1777 bombdoorcombo_l[3];
1778 bombdoorcset_l[3];
1779 bombdoorcombo_r[3];
1780 bombdoorcset_r[3];
1781 walkthroughcombo[4];
1782 walkthroughcset[4];
1783 */
1784 22848 }
1785
1786 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1787 {
1788 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1789 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1790 }
1791
1792 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1793 {
1794
1795 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1796 }
1797
1798 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1799 {
1800 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1801 }
1802
1803
1804 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1805 {
1806 char temp_pwd[30];
1807 83 memset(temp_pwd,0,30);
1808
1809
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1810 {
1811 75 memcpy(temp_pwd,encrypted_pwd,30);
1812 75 temp_pwd[29]=0;
1813
1814
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1815 {
1816 2250 temp_pwd[i] -= pwdkey;
1817 2250 int32_t t=pwdkey>>15;
1818 2250 pwdkey = (pwdkey<<1)+t;
1819 2250 }
1820 75 }
1821
1822 83 memcpy(pwd,temp_pwd,30);
1823 83 }
1824
1825
1826 254 bool devpwd()
1827 {
1828 #ifdef _DEBUG
1829 return true;
1830 #endif
1831 #if DEVLEVEL > 3
1832 return true;
1833 #endif
1834
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1835 }
1836 bool check_questpwd(zquestheader *Header, char *pwd)
1837 {
1838 if(devpwd())
1839 return true;
1840 if((!strcmp(pwd, (char*)clavio)))
1841 return true;
1842 cvs_MD5Context ctx;
1843 uint8_t md5sum[16];
1844
1845 cvs_MD5Init(&ctx);
1846 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1847 cvs_MD5Final(md5sum, &ctx);
1848
1849 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1850 }
1851
1852 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1853 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1854 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1855
1856 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1857 {
1858 char keyfilename[2048];
1859 replace_extension(keyfilename, path, ext, 2047);
1860 if(!exists(keyfilename))
1861 return false;
1862 bool ret = false;
1863
1864 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1865 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1866 char msg[80] = {0};
1867 pfread(msg, 80, fp);
1868 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1869 {
1870 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1871 pack_fclose(fp);
1872 return false;
1873 }
1874 int16_t ver;
1875 byte bld;
1876 p_igetw(&ver, fp);
1877 p_getc(&bld, fp);
1878 pfread(password, QSTPWD_LEN, fp, true);
1879 if(hashed)
1880 {
1881 char unhashed_pw[QSTPWD_LEN] = {0};
1882
1883 char hashmap = 'Z';
1884 hashmap += 'Q';
1885 hashmap += 'U';
1886 hashmap += 'E';
1887 hashmap += 'S';
1888 hashmap += 'T';
1889
1890 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1891 unhashed_pw[q] = password[q] - hashmap;
1892
1893 ret = check_questpwd(Header, unhashed_pw);
1894 }
1895 else ret = check_questpwd(Header, password);
1896 pack_fclose(fp);
1897 zprint2("Found %s Key File '%s' (%s access)\n",
1898 typestr, keyfilename, ret ? "valid" : "invalid");
1899 return ret;
1900 }
1901
1902 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1903 {
1904 char exedir[PATH_MAX] = {0};
1905 extract_name(path, exedir, FILENAMEALL);
1906 char const* paths[] = {path, exedir};
1907 for(uint keyty : types)
1908 {
1909 if(keyty >= KEYFILE_NUMTY)
1910 continue;
1911 for(char const* p : paths)
1912 {
1913 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1914 return true;
1915 }
1916 }
1917 return false;
1918 }
1919
1920 481 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1921 {
1922 481 zprint2("\n");
1923 481 zprint2("[QUEST METADATA]\n");
1924
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(path)
1925 481 zprint2("Path: %s\n", path);
1926
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 122 times.
481 if(tempheader.title[0])
1927 359 zprint2("Title: %s\n", tempheader.title);
1928 481 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1929
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 283 times.
481 if(tempheader.new_version_id_date_day)
1930 198 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1931
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 214 times.
481 if(tempheader.version[0])
1932 267 zprint2("Qst Version: %s\n", tempheader.version);
1933
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 122 times.
481 if(tempheader.author[0])
1934 359 zprint2("Author: %s\n", tempheader.author);
1935 481 zprint2("\n");
1936 481 }
1937
1938 816 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1939 {
1940 int32_t dummy;
1941 816 zquestheader tempheader{};
1942
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 12 times.
816 tempheader.filename = Header->filename;
1943 char dummybuf[80];
1944 byte temp_map_count;
1945 byte temp_midi_flags[MIDIFLAGS_SIZE];
1946 word version;
1947 char temp_pwd[30], temp_pwd2[30];
1948 int16_t temp_pwdkey;
1949 cvs_MD5Context ctx;
1950 804 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1951 804 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1952
1953
1954
1955
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
804 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1956 {
1957 Z_message("Unable to read header string\n");
1958 return qe_invalid;
1959 }
1960
1961 // check header
1962
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1963 {
1964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1965 {
1966 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1967 return qe_invalid;
1968 }
1969 24 }
1970
1971 804 int32_t templatepath_len=0;
1972
1973 804 tempheader.external_zinfo = false;
1974 804 read_zinfo = false;
1975
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1976 {
1977 byte padding;
1978
1979
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1980 {
1981 return qe_invalid;
1982 }
1983
1984
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1985 {
1986 return qe_invalid;
1987 }
1988
1989 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1990
1991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1992 {
1993 return qe_version;
1994 }
1995
1996 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1997
1998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1999 {
2000 return qe_invalid;
2001 }
2002
2003
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
2004 {
2005 return qe_obsolete;
2006 }
2007
2008
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_igetw(&tempheader.internal,f))
2009 {
2010 return qe_invalid;
2011 }
2012
2013
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.quest_number,f))
2014 {
2015 return qe_invalid;
2016 }
2017
2018 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2019
2020
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2021 {
2022 return qe_invalid;
2023 }
2024
2025
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
2026 {
2027 return qe_invalid;
2028 }
2029
2030 24 FFCore.quest_format[qMapCount] = temp_map_count;
2031
2032
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2033 {
2034 return qe_invalid;
2035 }
2036
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!pfread(temp_midi_flags,4,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2048 {
2049 return qe_invalid;
2050 }
2051
2052
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2053 {
2054 return qe_invalid;
2055 }
2056
2057
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2058 {
2059 return qe_invalid;
2060 }
2061
2062
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2063 {
2064 return qe_invalid;
2065 }
2066
2067
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2068 {
2069 return qe_invalid;
2070 }
2071
2072
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2073 {
2074 return qe_invalid;
2075 }
2076 // These fields are expected to end in null bytes!
2077 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2078
2079
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2080 {
2081 return qe_invalid;
2082 }
2083 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2084
2085
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2086 {
2087 return qe_invalid;
2088 }
2089
2090
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2091 {
2092 return qe_invalid;
2093 }
2094
2095
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2096 {
2097 return qe_invalid;
2098 }
2099
2100 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2101
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2102
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2103
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2104
2105
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2106 {
2107 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2108 // Not anymore...
2109 memset(tempheader.minver,0,17);
2110 tempheader.build=0;
2111 tempheader.use_keyfile=0;
2112 memset(tempheader.old_foo, 0, 9);
2113 }
2114 else
2115 {
2116
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2117 {
2118 return qe_invalid;
2119 }
2120
2121
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2122 {
2123 return qe_invalid;
2124 }
2125
2126 24 FFCore.quest_format[vBuild] = tempheader.build;
2127
2128
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2134 {
2135 return qe_invalid;
2136 }
2137 } // starting at minver
2138
2139
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2140 {
2141 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2142 6 }
2143 else
2144 {
2145
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2146 {
2147 return qe_invalid; // starting at rules3
2148 }
2149
2150
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2151 {
2152
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2153 12 }
2154 }
2155
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2156
2157
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2158
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2159 {
2160
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2161
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2162
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2163 18 }
2164
2165
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2166 {
2167 6 byte *mf=temp_midi_flags;
2168
2169
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2170 {
2171 4 mf=(byte*)dummybuf;
2172 4 }
2173
2174
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2175 {
2176 return qe_invalid; // starting at foo2
2177 }
2178
2179
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2180 {
2181 return qe_invalid; // starting at foo2
2182 }
2183 6 }
2184
2185
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2186
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2187 {
2188 18 memset(tempheader.templatepath,0,2048);
2189 18 }
2190 else
2191 {
2192 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2193 {
2194 return qe_invalid;
2195 }
2196 }
2197
2198
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2199
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2200 {
2201 24 tempheader.use_keyfile=0;
2202 24 }
2203 24 }
2204 else
2205 {
2206 //section id
2207
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_mgetl(&dummy,f))
2208 {
2209 return qe_invalid;
2210 }
2211
2212 //section version info
2213
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&version,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218 780 FFCore.quest_format[vHeader] = version;
2219
2220
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&dummy,f))
2221 {
2222 return qe_invalid;
2223 }
2224
2225 //section size
2226
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetl(&dummy,f))
2227 {
2228 return qe_invalid;
2229 }
2230
2231 //finally... section data
2232
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&tempheader.zelda_version,f))
2233 {
2234 return qe_invalid;
2235 }
2236
2237 780 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2238
2239 //do some quick checking...
2240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(tempheader.zelda_version > ZELDA_VERSION)
2241 {
2242 return qe_version;
2243 }
2244
2245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2246 {
2247 return qe_invalid;
2248 }
2249
2250
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 780 times.
780 if(bad_version(tempheader.zelda_version))
2251 {
2252 return qe_obsolete;
2253 }
2254
2255
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.build,f))
2256 {
2257 return qe_invalid;
2258 }
2259
2260 780 FFCore.quest_format[vBuild] = tempheader.build;
2261
2262
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 721 times.
780 if(version<3)
2263 {
2264
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2265 {
2266 return qe_invalid;
2267 }
2268
2269
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2270 {
2271 return qe_invalid;
2272 }
2273
2274 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2275
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2276
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2277
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2278 59 }
2279 else
2280 {
2281
2/4
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
721 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2282 {
2283 return qe_invalid;
2284 }
2285 }
2286
2287
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&tempheader.internal,f))
2288 {
2289 return qe_invalid;
2290 }
2291
2292
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.quest_number,f))
2293 {
2294 return qe_invalid;
2295 }
2296
2297 780 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2298
2299 780 size_t versz = version < 8 ? 9 : 16;
2300
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.version,versz,f))
2301 {
2302 return qe_invalid;
2303 }
2304
2305 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2306 //needs to be copied as char[9] or stored as a s.str
2307
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.minver,versz,f))
2308 {
2309 return qe_invalid;
2310 }
2311
2312 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2313
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2314 {
2315 return qe_invalid;
2316 }
2317 780 tempheader.title[sizeof(tempheader.title)-1] = 0;
2318
2319
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2320 {
2321 return qe_invalid;
2322 }
2323 780 tempheader.author[sizeof(tempheader.author)-1] = 0;
2324
2325
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.use_keyfile,f))
2326 {
2327 return qe_invalid;
2328 }
2329
2330 /*
2331 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2332 {
2333 return qe_invalid;
2334 }
2335 */
2336
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(&dummybuf,4,f))
2342 {
2343 return qe_invalid;
2344 }
2345
2346
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2347 {
2348 return qe_invalid;
2349 }
2350
2351
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(dummybuf,14,f))
2352 {
2353 return qe_invalid;
2354 }
2355
2356 780 templatepath_len=sizeof(tempheader.templatepath);
2357
2358
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 59 times.
780 if(version==1)
2359 {
2360 59 templatepath_len=280;
2361 59 }
2362
2363
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.templatepath,templatepath_len,f))
2364 {
2365 return qe_invalid;
2366 }
2367
2368
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&temp_map_count,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if(version>=4)
2374 {
2375
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.version_major,f))
2376 {
2377 return qe_invalid;
2378 }
2379
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.version_minor,f))
2380 {
2381 return qe_invalid;
2382 }
2383
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.version_patch,f))
2384 {
2385 return qe_invalid;
2386 }
2387
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2388 {
2389 return qe_invalid;
2390 }
2391
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2392 {
2393 return qe_invalid;
2394 }
2395
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_beta,f))
2396 {
2397 return qe_invalid;
2398 }
2399
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2400 {
2401 return qe_invalid;
2402 }
2403
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_release,f))
2404 {
2405 return qe_invalid;
2406 }
2407
2408 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2409
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2410 tempheader.version_minor = 55;
2411
2412
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2413 {
2414 return qe_invalid;
2415 }
2416
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_month,f))
2417 {
2418 return qe_invalid;
2419 }
2420
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_day,f))
2421 {
2422 return qe_invalid;
2423 }
2424
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2425 {
2426 return qe_invalid;
2427 }
2428
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2429 {
2430 return qe_invalid;
2431 }
2432
2433
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.new_version_devsig,256,f))
2434 {
2435 return qe_invalid;
2436 }
2437
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2438 strcpy(tempheader.new_version_devsig, "EmilyV99");
2439
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.new_version_compilername,256,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.new_version_compilerversion,256,f))
2444 {
2445 return qe_invalid;
2446 }
2447
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.product_name,1024,f))
2448 {
2449 return qe_invalid;
2450 }
2451
2452
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.compilerid,f))
2453 {
2454 return qe_invalid;
2455 }
2456
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2457 {
2458 return qe_invalid;
2459 }
2460
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2461 {
2462 return qe_invalid;
2463 }
2464
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2465 {
2466 return qe_invalid;
2467 }
2468
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2469 {
2470 return qe_invalid;
2471 }
2472
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&tempheader.developerid,f))
2473 {
2474 return qe_invalid;
2475 }
2476
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!pfread(tempheader.made_in_module_name,1024,f))
2477 {
2478 return qe_invalid;
2479 }
2480
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!pfread(tempheader.build_datestamp,256,f))
2481 {
2482 return qe_invalid;
2483 }
2484
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!pfread(tempheader.build_timestamp,256,f))
2485 {
2486 return qe_invalid;
2487 }
2488 198 }
2489 else // <4
2490 {
2491 582 tempheader.version_major = 0;
2492 582 tempheader.version_minor = 0;
2493 582 tempheader.version_patch = 0;
2494 582 tempheader.new_version_id_fourth = 0;
2495 582 tempheader.new_version_id_alpha = 0;
2496 582 tempheader.new_version_id_beta = 0;
2497 582 tempheader.new_version_id_gamma = 0;
2498 582 tempheader.new_version_id_release = 0;
2499 582 tempheader.new_version_id_date_year = 0;
2500 582 tempheader.new_version_id_date_month = 0;
2501 582 tempheader.new_version_id_date_day = 0;
2502 582 tempheader.new_version_id_date_hour = 0;
2503 582 tempheader.new_version_id_date_minute = 0;
2504
2505 582 memset(tempheader.new_version_devsig, 0, 256);
2506 582 memset(tempheader.new_version_compilername, 0, 256);
2507 582 memset(tempheader.new_version_compilerversion, 0, 256);
2508 582 memset(tempheader.product_name, 0, 1024);
2509 582 strcpy(tempheader.product_name, "ZQuest Classic");
2510
2511 582 tempheader.compilerid = 0;
2512 582 tempheader.compilerversionnumber_first = 0;
2513 582 tempheader.compilerversionnumber_second = 0;
2514 582 tempheader.compilerversionnumber_third = 0;
2515 582 tempheader.compilerversionnumber_fourth = 0;
2516 582 tempheader.developerid = 0;
2517
2518 582 memset(tempheader.made_in_module_name, 0, 1024);
2519 582 memset(tempheader.build_datestamp, 0, 256);
2520 582 memset(tempheader.build_timestamp, 0, 256);
2521 }
2522
2523
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if ( version >= 5 )
2524 {
2525
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.build_timezone,6,f))
2526 {
2527 return qe_invalid;
2528 }
2529 198 }
2530 else // < 5
2531 {
2532 582 memset(tempheader.build_timezone, 0, 6);
2533 }
2534
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if ( version >= 6 )
2535 {
2536 byte b;
2537
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&b,f))
2538 {
2539 return qe_invalid;
2540 }
2541 198 tempheader.external_zinfo = b?true:false;
2542 198 read_zinfo = true;
2543 198 }
2544
2545
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if(version >= 7)
2546 {
2547
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2548 {
2549 return qe_invalid;
2550 }
2551 198 }
2552 else
2553 {
2554 582 tempheader.new_version_is_nightly = false;
2555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 582 times.
582 if(tempheader.zelda_version < 0x255)
2556 {
2557
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
582 switch(tempheader.zelda_version)
2558 {
2559 case 0x254:
2560 tempheader.version_major = 2;
2561 tempheader.version_minor = 54;
2562 break;
2563 case 0x250:
2564
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 404 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 13 times.
523 switch(tempheader.build)
2565 {
2566 case 19:
2567 tempheader.version_major = 2;
2568 tempheader.version_minor = 50;
2569 tempheader.new_version_id_gamma = 1;
2570 break;
2571 case 20:
2572 tempheader.version_major = 2;
2573 tempheader.version_minor = 50;
2574 tempheader.new_version_id_gamma = 2;
2575 break;
2576 case 21:
2577 tempheader.version_major = 2;
2578 tempheader.version_minor = 50;
2579 tempheader.new_version_id_gamma = 3;
2580 break;
2581 case 22:
2582 tempheader.version_major = 2;
2583 tempheader.version_minor = 50;
2584 tempheader.new_version_id_gamma = 4;
2585 break;
2586 case 23:
2587 tempheader.version_major = 2;
2588 tempheader.version_minor = 50;
2589 tempheader.new_version_id_gamma = 5;
2590 break;
2591 case 24:
2592 31 tempheader.version_major = 2;
2593 31 tempheader.version_minor = 50;
2594 31 tempheader.new_version_id_release = -1;
2595 31 break;
2596 case 25:
2597 tempheader.version_major = 2;
2598 tempheader.version_minor = 50;
2599 tempheader.version_patch = 1;
2600 tempheader.new_version_id_gamma = 1;
2601 break;
2602 case 26:
2603 24 tempheader.version_major = 2;
2604 24 tempheader.version_minor = 50;
2605 24 tempheader.version_patch = 1;
2606 24 tempheader.new_version_id_gamma = 2;
2607 24 break;
2608 case 27:
2609 tempheader.version_major = 2;
2610 tempheader.version_minor = 50;
2611 tempheader.version_patch = 1;
2612 tempheader.new_version_id_gamma = 3;
2613 break;
2614 case 28:
2615 6 tempheader.version_major = 2;
2616 6 tempheader.version_minor = 50;
2617 6 tempheader.version_patch = 1;
2618 6 tempheader.new_version_id_release = -1;
2619 6 break;
2620 case 29:
2621 404 tempheader.version_major = 2;
2622 404 tempheader.version_minor = 50;
2623 404 tempheader.version_patch = 2;
2624 404 tempheader.new_version_id_release = -1;
2625 404 break;
2626 case 30:
2627 tempheader.version_major = 2;
2628 tempheader.version_minor = 50;
2629 tempheader.version_patch = 3;
2630 tempheader.new_version_id_gamma = 1;
2631 break;
2632 case 31:
2633 16 tempheader.version_major = 2;
2634 16 tempheader.version_minor = 53;
2635 16 tempheader.new_version_id_gamma = -1;
2636 16 break;
2637 case 32:
2638 29 tempheader.version_major = 2;
2639 29 tempheader.version_minor = 53;
2640 29 tempheader.new_version_id_release = -1;
2641 29 break;
2642 case 33:
2643 13 tempheader.version_major = 2;
2644 13 tempheader.version_minor = 53;
2645 13 tempheader.version_patch = 1;
2646 13 break;
2647 }
2648 523 break;
2649
2650 case 0x211:
2651 tempheader.version_major = 2;
2652 tempheader.version_minor = 11;
2653 tempheader.new_version_id_beta = tempheader.build;
2654 break;
2655 case 0x210:
2656 59 tempheader.version_major = 2;
2657 59 tempheader.version_minor = 10;
2658 59 tempheader.new_version_id_beta = tempheader.build;
2659 59 break;
2660 }
2661 582 }
2662 }
2663
2664
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 626 times.
780 if (version>=9)
2665 {
2666 154 std::string version_string;
2667
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if(!p_getcstr(&version_string, f))
2668 {
2669 return qe_invalid;
2670 }
2671
2672 154 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2673 154 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 }
2675 else
2676 {
2677 626 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2678 }
2679 }
2680
2681
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 747 times.
804 if(printmetadata)
2682 {
2683
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2684 57 }
2685
2686 //{ Version Warning
2687
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 int32_t vercmp = tempheader.compareVer();
2688
3/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 804 times.
✗ Branch 5 not taken.
804 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2689
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
804 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2690
4/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✓ Branch 3 taken 650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 154 times.
958 if(vercmp > 0 || (!vercmp &&
2691
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 (astatecmp > 0 || (!astatecmp &&
2692 154 avercmp > 0))))
2693 {
2694 bool r = true;
2695 if(loadquest_report)
2696 {
2697 enter_sys_pal();
2698 AlertDialog("Quest saved in newer version",
2699 "This quest was last saved in a newer version of ZQuest."
2700 " Attempting to load this quest may not work correctly; to"
2701 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2702 "\n\nWould you like to continue loading anyway? (Not recommended)",
2703 [&](bool ret,bool)
2704 {
2705 r = ret;
2706 }).show();
2707 exit_sys_pal();
2708 }
2709 if(!r)
2710 return qe_silenterr;
2711 }
2712
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
804 else if(tempheader.compareDate() > 0)
2713 {
2714 bool r = true;
2715 if(loadquest_report)
2716 {
2717 enter_sys_pal();
2718 AlertDialog("Quest saved in newer build",
2719 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2720 " issues loading in this build."
2721 "\n{}"
2722 "\n\nWould you like to continue loading anyway?",
2723 tempheader.getVerCmpStr()),
2724 [&](bool ret,bool)
2725 {
2726 r = ret;
2727 }).show();
2728 exit_sys_pal();
2729 }
2730 if(!r)
2731 return qe_silenterr;
2732 }
2733 //}
2734
2735 804 read_ext_zinfo = tempheader.external_zinfo;
2736
2737
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 *Header = tempheader;
2738 804 map_count=temp_map_count;
2739 804 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2740
2741
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 unpack_qrs();
2742
2743 804 return 0;
2744 828 }
2745
2746 10424 int32_t readrules(PACKFILE *f, zquestheader *Header)
2747 {
2748
2/2
✓ Branch 0 taken 10401 times.
✓ Branch 1 taken 23 times.
10424 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10424 times.
10424 if (should_skip)
2750 return 0;
2751
2752 int32_t dummy;
2753 10424 zquestheader tempheader = *Header;
2754 10424 word s_version=0;
2755 10424 dword compatrule_version=0;
2756
2757
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 9967 times.
10424 if(tempheader.zelda_version >= 0x193)
2758 {
2759 //section version info
2760
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
2761 {
2762 return qe_invalid;
2763 }
2764
2765 457 FFCore.quest_format[vRules] = s_version;
2766
2767
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dummy,f))
2768 {
2769 return qe_invalid;
2770 }
2771
2772
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 259 times.
457 if(s_version > 16)
2773 {
2774
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&compatrule_version,f))
2775 {
2776 return qe_invalid;
2777 }
2778 198 }
2779 457 FFCore.quest_format[vCompatRule] = compatrule_version;
2780
2781 //section size
2782
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
2783 {
2784 return qe_invalid;
2785 }
2786
2787
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 198 times.
457 if ( s_version < 15 )
2788 {
2789 //finally... section data
2790
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2791 {
2792 return qe_invalid;
2793 }
2794 259 }
2795 else
2796 {
2797
2798
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2799 {
2800 return qe_invalid;
2801 }
2802
2803 }
2804 457 }
2805
2806 //{ bunch of compat stuff
2807 10424 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2808
2809
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 9944 times.
10424 unpack_qrs();
2810
2811
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<2)
2812 {
2813
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2814
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2815
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2816
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2817
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2818
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2819
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2820
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2821
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2822
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2823
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2824
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2825
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2826
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2827
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2828
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2829
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2830
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2831
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2832 82 }
2833
2834 //Now, do any updates...
2835
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
480 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2836 {
2837
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2838
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2839
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2840
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2841
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2842 82 }
2843
2844
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2845 {
2846
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2847 23 }
2848
2849
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2850 {
2851
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2852 23 }
2853
2854
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2855 {
2856
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2857 23 }
2858
2859
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version <= 0x210)
2860 {
2861
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2862 82 }
2863
2864
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 421 times.
480 if(tempheader.zelda_version == 0x210)
2865 {
2866
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2867
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2868
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2869 59 }
2870
2871
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version <= 0x210)
2872 {
2873
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2874
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2875 82 }
2876
2877 //might not be correct
2878
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(tempheader.zelda_version < 0x210)
2879 {
2880
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2881
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2882
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2883 23 }
2884
2885
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version < 0x211)
2886 {
2887
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2888 82 }
2889
2890
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 475 times.
480 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2891 {
2892
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 458 times.
480 set_qr(qr_192b163_WARP,1);
2893 22 }
2894
2895
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 49 times.
22 if(tempheader.zelda_version == 0x210)
2896 {
2897
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2898
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2899
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2900 59 }
2901
2902
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
108 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2903 {
2904
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 set_qr(qr_OLDPICKUP,1);
2905 82 }
2906
2907
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
480 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2908 {
2909
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2910
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2911 82 }
2912
2913
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2914 {
2915
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2916 82 }
2917
2918
4/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 169 times.
480 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2919 {
2920
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_PEAHATCLOCKVULN, 1);
2921 31 }
2922
2923
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
480 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2924 {
2925
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 set_qr(qr_OLD_DOORREPAIR, 1);
2926 82 }
2927
2928
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
280 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2929 {
2930
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 236 times.
318 set_qr(qr_OLD_SECRETMONEY, 1);
2931 82 }
2932
2933
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
280 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2934 {
2935
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 181 times.
318 set_qr(qr_OLD_POTION_OR_HC, 1);
2936 137 }
2937
2938
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
335 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2939 {
2940
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 126 times.
263 set_qr(qr_OFFSCREENWEAPONS, 1);
2941 137 }
2942
2943 //Bombchu fix.
2944
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 200 times.
335 if(tempheader.zelda_version == 0x250)
2945 {
2946
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 169 times.
200 if ( tempheader.build == 24 ) //2.50.0
2947 {
2948
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2949 31 }
2950
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 194 times.
200 if ( tempheader.build == 28 ) //2.50.1
2951 {
2952
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2953 6 }
2954
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 119 times.
200 if ( tempheader.build == 29 ) //2.50.2
2955 {
2956
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2957 81 }
2958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if ( tempheader.build == 30 ) //2.50.3RC1
2959 {
2960 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2961 }
2962 200 }
2963
2964
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
345 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2965 {
2966 // qr_OFFSETEWPNCOLLISIONFIX
2967 // All 'official' quests need this disabled.
2968 // All 2.10 and lower quests need this enabled to preseve compatability.
2969 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2970
2971 //~Gleeok
2972
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 110 times.
253 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2973
2974 // Broke in build 695
2975
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
143 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2976
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 set_qr(qr_BROKENSTATUES, 1);
2977 143 }
2978
11/14
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 462 times.
✓ Branch 2 taken 457 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 578 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 578 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 561 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
341 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2979 {
2980
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2981 22 }
2982
8/8
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 383 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 198 times.
✓ Branch 7 taken 13 times.
583 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2983 {
2984
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 301 times.
570 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2985 269 }
2986
2987
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2988 {
2989
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2990 82 }
2991
2992
4/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 198 times.
282 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2993 {
2994
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 112 times.
170 set_qr(qr_STEP_IS_FLOAT,0);
2995 282 }
2996
2997
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if ( tempheader.zelda_version < 0x250 )
2998 {
2999
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
3000 82 }
3001
3002
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version < 3)
3003 {
3004
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3005
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3006 82 }
3007
3008
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<4)
3009 {
3010
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
3011 82 }
3012
3013
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<5)
3014 {
3015
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
3016 82 }
3017
3018
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<6)
3019 {
3020
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
3021 82 }
3022
3023
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<7) // January 2008
3024 {
3025
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
3026
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3027 82 }
3028
3029
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<8)
3030 {
3031
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3032 82 }
3033 else
3034 {
3035
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 set_bit(deprecated_rules, 12, 0);
3036 }
3037
3038
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<9) // October 2008
3039 {
3040
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3041
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3042
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3043
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3044 82 }
3045
3046
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<10) // December 2008
3047 {
3048
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3049
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3050 82 }
3051
3052
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<11) // April 2009
3053 {
3054
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3055 82 }
3056
3057 // This served no purpose.
3058 // if(s_version<12) // December 2009
3059 // {
3060 // set_qr(qr_BRKBLSHLDS_DEP,0);
3061 // set_qr(qr_OLDTRIBBLES_DEP,0);
3062 // }
3063
3064 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3065
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version < 13)
3066 {
3067
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3068 82 }
3069
3070 // Not entirely sure this is the best place for this...
3071 //2.50.2 bitmap offset fix
3072 480 memset(extra_rules, 0, EXTRARULES_SIZE);
3073
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
480 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3074 {
3075
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 139 times.
282 set_er(er_BITMAPOFFSET, 1);
3076
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 set_qr(qr_BITMAPOFFSETFIX, 1);
3077 143 }
3078 //required because quest templates also used this bit, although
3079 //it never did anything, before. -Z
3080
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 151 times.
341 if ( tempheader.zelda_version == 0x250 )
3081 {
3082
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 103 times.
200 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3083 {
3084
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_er(er_BITMAPOFFSET, 0);
3085
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_qr(qr_BITMAPOFFSETFIX, 0);
3086 97 }
3087 200 }
3088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
351 if ( tempheader.zelda_version == 0x254 )
3089 {
3090 set_er(er_BITMAPOFFSET, 0);
3091 set_qr(qr_BITMAPOFFSETFIX, 0);
3092 }
3093
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
351 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3094 {
3095 set_er(er_BITMAPOFFSET, 0);
3096 set_qr(qr_BITMAPOFFSETFIX, 0);
3097 }
3098 //optimise fast drawing for older versions.
3099
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 153 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
351 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3100 {
3101
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 107 times.
351 set_qr(qr_OLDSPRITEDRAWS, 1);
3102 282 }
3103 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3104 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3105 //older quests can set the rule by hand. We need a new qst.dat again.
3106
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3107 {
3108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 set_qr(qr_OLDEWPNPARENT, 1);
3109 }
3110
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3111 {
3112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3113 }
3114
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3115 {
3116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 set_qr(qr_OLDQUESTMISC, 1);
3117 }
3118
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3119 {
3120
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3121
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDEWPNPARENT, 0);
3122
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDQUESTMISC, 0);
3123 282 }
3124
3125 //item scripts continue to run
3126
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3127 {
3128
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3129
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3130
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3131
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3132
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3133
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3134
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3135 282 }
3136
3137
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3138 {
3139
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3140 282 }
3141
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3142 {
3143
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_TRACESCRIPTIDS, 0);
3144
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3145
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3146
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_250DIVISION,1);
3147
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3148
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3149
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_FORCE_INLINE,0);
3150
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BINARY_32BIT,0);
3151
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 274 times.
282 if ( get_qr(qr_SELECTAWPN) )
3152 {
3153
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3154 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3155 //Now they **do**, unless you disable that behaviour.
3156 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3157 //now enable the disable L/R item swap on load.
3158 8 }
3159
3160 282 }
3161
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3162 {
3163 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3164
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3165 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3166 //animations ending earlier than they should.
3167
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3168 //Enemies would ignore solidity on the top half of combos
3169
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3170 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3171
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3172 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3173
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3174 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3175
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3176 282 }
3177
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x255 )
3178 {
3179
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOFFCWAITDRAW, 1);
3180
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOITEMWAITDRAW, 1);
3181
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3182
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3183 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3184 282 }
3185
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3186 {
3187
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3188 282 }
3189
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3190 {
3191
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_OLD_PRINTF_ARGS, 1);
3192 282 }
3193
3194
3195
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3196 {
3197
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_BROKEN_RING_POWER, 1);
3198 282 }
3199
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3200 {
3201
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3202 282 }
3203
5/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✓ Branch 5 taken 86 times.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3204 {
3205
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3206 282 }
3207
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
368 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3208 {
3209 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
368 if(get_qr(qr_SET_XBUTTON_ITEMS))
3211 set_qr(qr_SET_YBUTTON_ITEMS,1);
3212 282 }
3213
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3214 {
3215
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3216 282 }
3217
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3218 {
3219
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_OLD_CHEST_COLLISION,1);
3220 282 }
3221
3222
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3223 {
3224
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3225 282 }
3226 //Sideview spikes in 2.50.0
3227
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
282 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3228 {
3229
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 187 times.
324 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3230 137 }
3231 //more 2.50 fixes -Z
3232
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
335 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3233 {
3234
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 49 times.
263 set_qr(qr_MELEEMAGICCOST, 0);
3235
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3236
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_OLDMIRRORCOMBOS, 1);
3237
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENBOOKCOST, 1);
3238
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENCHARINTDRAWING, 1);
3239
3240 224 }
3241
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
422 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3242 {
3243 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3244 set_qr(qr_MELEEMAGICCOST, 1);
3245 }
3246
3247
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 399 times.
422 if(tempheader.zelda_version < 0x193)
3248 {
3249
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3250 23 }
3251
3252
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 140 times.
422 if(tempheader.zelda_version < 0x255)
3253 {
3254
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDINFMAGIC, 1);
3255 282 }
3256
3257
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 340 times.
422 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3258 {
3259
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3260 82 }
3261
3262
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
422 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3263 {
3264
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 140 times.
422 set_qr(qr_OLD_F6,1);
3265 282 }
3266
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3267 {
3268
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3269 282 }
3270
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3271 {
3272
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3273 282 }
3274
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3275 {
3276
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3277 282 }
3278 //}
3279
3280
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3281
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3282
3283
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 2) //Old CSet2 Handling
3284
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCS2,1);
3285
3286
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3287
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3288
3289
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3290
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3291
3292
3/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 82 times.
282 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3293
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3294
3295
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3296
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3297
3298
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3299
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3300
3301
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3302
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3303
3304
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 9)
3305 {
3306 //Hardcoded BS Patras
3307
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_BS_PATRA,1);
3308 //Hardcoded Patra Inner Eye offsets
3309
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3310 //Broken 'Big enemy' animation style
3311
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3312 //Broken Attribute 31/32
3313
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3314 282 }
3315
3316
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 10) //Shared candle use limits
3317
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3318
3319
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 11) //No cross-screen return points
3320
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_RESPAWN_POINTS,1);
3321
3322
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 12)
3323 {
3324 //Old fire trail duration
3325
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3326 //Old Intro String in Ganon Room Behavior
3327
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3328
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_GANONINTRO,1);
3329 282 }
3330
3331
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
282 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3332 set_qr(qr_ANONE_NOANIM,1);
3333
3334
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 14) //Old Bridge Combo Behavior
3335
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3336
3337
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 15) //Broken Z3 Animation
3338
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3339
3340
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3341
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3342
3343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 17)
3344 {
3345 //Old Quake/DrawYOffset behavior
3346 //set_qr(qr_OLD_DRAWOFFSET,1);
3347 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3348 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3349 282 }
3350
3351
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 18)
3352 {
3353 //Broken DrawScreen Derivative Functions
3354
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3355 //Scrolling Cancels Charge
3356
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3357 282 }
3358
3359
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3360
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3361
3362
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 20)
3363
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3364
3365
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 21)
3366 {
3367
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3368
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3369
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3370
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BUG_NET,1);
3371
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3372 282 }
3373
3374
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 22)
3375
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3376
3377
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 23)
3378
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_HALF_MAGIC,1);
3379
3380
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 24)
3381 {
3382
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3383
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3384 282 }
3385
3386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 25)
3387 {
3388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3389
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3390
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3391 282 }
3392
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 26)
3393 {
3394
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3395
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_POLVIRE_NO_SHADOW,1);
3396
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3397 282 }
3398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3399 {
3400
2/2
✓ Branch 0 taken 84882 times.
✓ Branch 1 taken 282 times.
85164 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3401
1/2
✓ Branch 0 taken 84882 times.
✗ Branch 1 not taken.
84882 set_qr(q,0);
3402
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 282 times.
1974 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3403
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 set_qr(q,0);
3404 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3405 282 }
3406
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
282 if(compatrule_version < 28)
3407
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3408
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 29)
3409
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3410
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 30)
3411 {
3412
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DECO_2_YOFFSET,1);
3413
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCREENSTATE_80s_BUG,1);
3414 287 }
3415
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 31)
3416 {
3417
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3418
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3419 287 }
3420
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 32)
3421
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3422
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 33)
3423
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NO_LIFT_SPRITE,1);
3424
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 34)
3425 {
3426
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3427
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3428
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3429
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3430 287 }
3431
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 35)
3432 {
3433
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3434
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3435 289 }
3436
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 36)
3437
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_OLD_SHALLOW_SFX,1);
3438
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
294 if(compatrule_version < 37)
3439
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3440
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 38)
3441
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3442
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 39)
3443
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3444
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 40)
3445
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3446
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 41)
3447
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKENHITBY,1);
3448
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 42)
3449
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3450
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 43)
3451
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_OLD_BOMB_HITBOXES,1);
3452
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 44)
3453
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3454
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 45)
3455
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3456
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 46)
3457
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3458
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 47)
3459 {
3460
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3461
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3462 299 }
3463
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 48)
3464
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GUY_HANDLING,1);
3465
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 49)
3466
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3467
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 50)
3468
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3469
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 51)
3470
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3471
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if (compatrule_version < 52)
3472
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3473
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 53)
3474 {
3475
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SUBSCR,1);
3476
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3477
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3478 299 }
3479
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 54)
3480
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3481
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 55)
3482
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3483
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 56)
3484
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3485
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 57)
3486
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3487
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 58)
3488
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3489
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 59)
3490
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3491
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 60)
3492
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3493
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 61)
3494
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3495
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 62)
3496
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3497
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 2 times.
302 if(compatrule_version < 63)
3498 {
3499
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_LIFTSWIM,1);
3500
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3501 300 }
3502
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 2 times.
302 if(compatrule_version < 64)
3503
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3504
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 23 times.
302 if(compatrule_version < 65)
3505
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3506
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 66)
3507
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3508
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 67)
3509
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3510
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 68)
3511
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3512
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 69)
3513
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3514
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 70)
3515
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_CONVEYORS, 1);
3516
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 71)
3517
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3518
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 72)
3519
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3520
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 73)
3521 {
3522
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_LANDING_SFX, 1);
3523
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3524 327 }
3525
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
348 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3526
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3527
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 347 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
674 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3528
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3529
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 673 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1000 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3530
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3531
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 77)
3532
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3533
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 78)
3534
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3535
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 79)
3536
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3537
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 80)
3538
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3539
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1326 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3540
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3541
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1301 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1652 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3542
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3543
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1627 times.
1978 if (compatrule_version < 82)
3544 {
3545
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_EW_ROCKS_HARDCODED_BREAK_ON_SOLID, 1);
3546
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_IMPRECISE_WEAPON_SOLIDITY_CHECKS, 1);
3547 351 }
3548
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1627 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1978 if (compatrule_version < 83 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3549
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_BROKEN_BLOCKHOLE_PITFALLS, 1);
3550
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1953 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2304 if (compatrule_version < 84 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3551
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_CUSTOM_WEAPON_BROKEN_SIZE, 1);
3552
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2278 times.
2630 if (compatrule_version < 85)
3553
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_OLD_WEAPON_REFLECTION, 1);
3554
5/6
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 2226 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2630 if (compatrule_version < 86 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3555
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 326 times.
78 set_qr(qr_OLD_SPRITE_FALL_DROWN, 1);
3556
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 2552 times.
2956 if (compatrule_version < 87)
3557
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 set_qr(qr_OLD_TERMINAL_VELOCITY, 1);
3558
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 2552 times.
2956 if (compatrule_version < 88)
3559
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 set_qr(qr_OLD_SCRIPT_LEVEL_GLOBAL_STATES, 1);
3560
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 2552 times.
2956 if (compatrule_version < 89)
3561
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 set_qr(qr_BROKEN_ARMOS_GRAVE_BIGHITBOX_COLLISION, 1);
3562
3563
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 2552 times.
2956 if (compatrule_version < 90)
3564 {
3565
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 set_qr(qr_CLASSIC_DRAWING_ORDER, 1);
3566
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 set_qr(qr_OLD_WEAPON_DRAW_ANIMATE_TIMING, 1);
3567 404 }
3568
3569
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2476 times.
2956 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3570
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 198 times.
480 if (s_version < 16)
3571
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3572
3573
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 *Header = tempheader;
3574
3575 480 return 0;
3576 20368 }
3577
3578 4072985 void init_msgstr(MsgStr *str)
3579 {
3580
2/4
✓ Branch 0 taken 4072985 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4072985 times.
4072985 str->setFromLegacyEncoding("");
3581 4072985 str->nextstring=0;
3582 4072985 str->tile=0;
3583 4072985 str->cset=0;
3584 4072985 str->trans=false;
3585 4072985 str->font=font_zfont;
3586 4072985 str->y=32;
3587 4072985 str->sfx=18;
3588 4072985 str->listpos=0;
3589 4072985 str->x=24;
3590 4072985 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3591 4072985 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3592 4072985 str->hspace=0;
3593 4072985 str->vspace=0;
3594 4072985 str->stringflags=0;
3595 4072985 str->margins[up] = 8;
3596 4072985 str->margins[down] = 0;
3597 4072985 str->margins[left] = 8;
3598 4072985 str->margins[right] = 8;
3599 4072985 str->portrait_tile = 0;
3600 4072985 str->portrait_cset = 0;
3601 4072985 str->portrait_x = 0;
3602 4072985 str->portrait_y = 0;
3603 4072985 str->portrait_tw = 1;
3604 4072985 str->portrait_th = 1;
3605 4072985 str->shadow_type = 0;
3606 4072985 str->shadow_color = 0;
3607 4072985 str->drawlayer = 6;
3608 4072985 }
3609
3610 480 void init_msgstrings(int32_t start, int32_t end)
3611 {
3612
2/4
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 480 times.
480 if(end <= start || end-start > msg_strings_size)
3613 return;
3614
3615
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 3932160 times.
3932640 for(int32_t i=start; i<end; i++)
3616 {
3617 3932160 init_msgstr(&MsgStrings[i]);
3618 3932160 MsgStrings[i].listpos=i;
3619 3932160 }
3620
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(start==0)
3622 {
3623
2/4
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 480 times.
480 MsgStrings[0].setFromLegacyEncoding("(None)");
3624 480 MsgStrings[0].listpos = 0;
3625 480 }
3626 480 }
3627
3628 481 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3629 {
3630
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3631
3632 481 MsgStr tempMsgString;
3633
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 init_msgstr(&tempMsgString);
3634
3635 481 word temp_msg_count=0;
3636 word temp_expansion[16];
3637 481 memset(temp_expansion, 0, 16*sizeof(word));
3638 481 char buf[8193] = {0};
3639
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(Header->zelda_version < 0x193)
3640 {
3641 byte tempbyte;
3642 24 int32_t strings_to_read=0;
3643
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3644
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3645
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3646
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3647 {
3648 18 strings_to_read=128;
3649 18 temp_msg_count=Header->old_str_count;
3650
3651 // Some sort of string count corruption seems to be common in old quests
3652
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3653 {
3654 temp_msg_count=128;
3655 }
3656 18 }
3657
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3658 {
3659 strings_to_read=255;
3660 temp_msg_count=Header->old_str_count;
3661 }
3662 else
3663 {
3664
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3665 {
3666 return qe_invalid;
3667 }
3668
3669 6 strings_to_read=temp_msg_count;
3670
3671
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3672 {
3673 Z_message("Reallocating string buffer...\n");
3674
3675 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3676 // return qe_nomem;
3677
3678 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3679 delete[] MsgStrings;
3680 MsgStrings = new MsgStr[MAXMSGS];
3681 msg_strings_size = MAXMSGS;
3682 for(auto q = 0; q < msg_strings_size; ++q)
3683 {
3684 MsgStrings[q].clear();
3685 }
3686 }
3687 }
3688
3689 //reset the message strings
3690
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3691
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3692
3693
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3694 {
3695
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3696 2550 tempMsgString.listpos = x;
3697
3698
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3699 {
3700 return qe_invalid;
3701 }
3702
3703 2550 buf[74] = '\0';
3704
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3705
3706
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3707 {
3708 return qe_invalid;
3709 }
3710
3711
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3712
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3713 {
3714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3715
3716
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3717 {
3718 return qe_invalid;
3719 }
3720
3721
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3722 {
3723 return qe_invalid;
3724 }
3725 2304 }
3726 else
3727 {
3728
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3729 {
3730 return qe_invalid;
3731 }
3732
3733
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3734 {
3735 return qe_invalid;
3736 }
3737 }
3738
3739
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3740 {
3741
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3742 2549 }
3743 2550 }
3744 24 }
3745 else
3746 {
3747 int32_t dummy_int;
3748 word s_version;
3749
3750 //section version info
3751
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
3752 {
3753 return qe_invalid;
3754 }
3755
3756 457 FFCore.quest_format[vStrings] = s_version;
3757
3758
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
3759 {
3760 return qe_invalid;
3761 }
3762
3763 //section size
3764
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy_int,f))
3765 {
3766 return qe_invalid;
3767 }
3768
3769 //finally... section data
3770
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&temp_msg_count,f))
3771 {
3772 return qe_invalid;
3773 }
3774
3775
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
457 if(temp_msg_count >= msg_strings_size && !should_skip)
3776 {
3777 Z_message("Reallocating string buffer...\n");
3778
3779 delete[] MsgStrings;
3780 MsgStrings = new MsgStr[MAXMSGS];
3781 msg_strings_size = MAXMSGS;
3782 for(auto q = 0; q < msg_strings_size; ++q)
3783 {
3784 MsgStrings[q].clear();
3785 }
3786 }
3787
3788 //reset the message strings
3789
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 198 times.
457 if(s_version < 7)
3790
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3791
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (!should_skip)
3792
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 init_msgstrings(0,msg_strings_size);
3793
3794 457 int32_t string_length=(s_version<2)?73:145;
3795
3796
2/2
✓ Branch 0 taken 137794 times.
✓ Branch 1 taken 457 times.
138251 for(int32_t i=0; i<temp_msg_count; i++)
3797 {
3798
1/2
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
137794 init_msgstr(&tempMsgString);
3799 137794 tempMsgString.listpos = i;
3800
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 131926 times.
137794 if(s_version > 8)
3801 {
3802
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_igetl(&string_length,f))
3803 {
3804 return qe_invalid;
3805 }
3806 5868 }
3807
3808
2/4
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 137794 times.
137794 if (string_length < 0 || string_length > 8193)
3809 {
3810 return qe_invalid;
3811 }
3812
3813
2/2
✓ Branch 0 taken 137242 times.
✓ Branch 1 taken 552 times.
137794 if (string_length > 0)
3814 {
3815
2/4
✓ Branch 0 taken 137242 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137242 times.
✗ Branch 3 not taken.
137242 if (!pfread(buf, string_length, f))
3816 {
3817 return qe_invalid;
3818 }
3819 137242 }
3820 else
3821 {
3822 552 buf[0] = 0;
3823 }
3824
3825
2/4
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137794 times.
✗ Branch 3 not taken.
137794 if(!p_igetw(&tempMsgString.nextstring,f))
3826 {
3827 return qe_invalid;
3828 }
3829
3830
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 104181 times.
137794 if(s_version<2)
3831 {
3832 33613 buf[72] = '\0';
3833
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3834 33613 }
3835 else
3836 {
3837 // June 2008: A bug corrupted the last 4 chars of a string.
3838 // Discard these.
3839
1/2
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
104181 if(s_version<3)
3840 {
3841 for(int32_t j=140; j<144; j++)
3842 {
3843 buf[j] = '\0';
3844 }
3845 }
3846
1/2
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
104181 if(string_length > 8192) string_length = 8192;
3847 104181 buf[string_length]='\0'; //Force-terminate
3848
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104181 times.
104181 tempMsgString.setFromLegacyEncoding(buf);
3849
3850
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 98313 times.
104181 if ( s_version >= 6 )
3851 {
3852
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_igetl(&tempMsgString.tile,f))
3853 {
3854 return qe_invalid;
3855 }
3856 5868 }
3857 else
3858 {
3859
2/4
✓ Branch 0 taken 98313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98313 times.
✗ Branch 3 not taken.
98313 if(!p_igetw(&tempMsgString.tile,f))
3860 {
3861 return qe_invalid;
3862 }
3863 }
3864
3865
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.cset,f))
3866 {
3867 return qe_invalid;
3868 }
3869
3870 byte dummy_char;
3871
3872
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3873 {
3874 return qe_invalid;
3875 }
3876
3877 104181 tempMsgString.trans=dummy_char!=0;
3878
3879
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.font,f))
3880 {
3881 return qe_invalid;
3882 }
3883
3884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104181 times.
104181 if(s_version < 5)
3885 {
3886 if(!p_getc(&tempMsgString.y,f))
3887 {
3888 return qe_invalid;
3889 }
3890 }
3891 else
3892 {
3893
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.x,f))
3894 {
3895 return qe_invalid;
3896 }
3897
3898
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.y,f))
3899 {
3900 return qe_invalid;
3901 }
3902
3903
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.w,f))
3904 {
3905 return qe_invalid;
3906 }
3907
3908
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.h,f))
3909 {
3910 return qe_invalid;
3911 }
3912
3913
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.hspace,f))
3914 {
3915 return qe_invalid;
3916 }
3917
3918
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.vspace,f))
3919 {
3920 return qe_invalid;
3921 }
3922
3923
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.stringflags,f))
3924 {
3925 return qe_invalid;
3926 }
3927 }
3928
3929
2/2
✓ Branch 0 taken 98313 times.
✓ Branch 1 taken 5868 times.
104181 if(s_version >= 7)
3930 {
3931
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 23472 times.
29340 for(int32_t q = 0; q < 4; ++q)
3932 {
3933
2/4
✓ Branch 0 taken 23472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23472 times.
✗ Branch 3 not taken.
23472 if(!p_getc(&tempMsgString.margins[q],f))
3934 {
3935 return qe_invalid;
3936 }
3937 23472 }
3938
3939
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_igetl(&tempMsgString.portrait_tile,f))
3940 {
3941 return qe_invalid;
3942 }
3943
3944
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_cset,f))
3945 {
3946 return qe_invalid;
3947 }
3948
3949
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_x,f))
3950 {
3951 return qe_invalid;
3952 }
3953
3954
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_y,f))
3955 {
3956 return qe_invalid;
3957 }
3958
3959
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_tw,f))
3960 {
3961 return qe_invalid;
3962 }
3963
3964
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_th,f))
3965 {
3966 return qe_invalid;
3967 }
3968 5868 }
3969
3970
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 98313 times.
104181 if(s_version >= 8)
3971 {
3972
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.shadow_type,f))
3973 {
3974 return qe_invalid;
3975 }
3976
3977
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.shadow_color,f))
3978 {
3979 return qe_invalid;
3980 }
3981 5868 }
3982
3983
2/2
✓ Branch 0 taken 5559 times.
✓ Branch 1 taken 98622 times.
104181 if(s_version >= 10)
3984 {
3985
2/4
✓ Branch 0 taken 5559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5559 times.
✗ Branch 3 not taken.
5559 if(!p_getc(&tempMsgString.drawlayer,f))
3986 {
3987 return qe_invalid;
3988 }
3989 5559 }
3990
3991
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.sfx,f))
3992 {
3993 return qe_invalid;
3994 }
3995
3996
1/2
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
104181 if(s_version>3)
3997 {
3998
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.listpos,f))
3999 {
4000 return qe_invalid;
4001 }
4002 104181 }
4003 }
4004
4005
1/2
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
137794 if (!should_skip)
4006 {
4007
1/2
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
137794 MsgStrings[i].copyAll(tempMsgString);
4008 137794 }
4009 137794 }
4010 }
4011
4012
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
4013 480 msg_count=temp_msg_count;
4014
4015 481 return 0;
4016 481 }
4017
4018 481 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4019 {
4020
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4021
4022
3/4
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
487 if((Header->zelda_version < 0x192)||
4023
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 457 times.
463 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4024 {
4025 18 return 0;
4026 }
4027
4028 463 word temp_door_combo_set_count=0;
4029 DoorComboSet tempDoorComboSet;
4030 word dummy_word;
4031 int32_t dummy_long;
4032 byte padding;
4033 463 int32_t s_version = 0;
4034
4035
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 462 times.
463 if (!should_skip)
4036 {
4037 462 DoorComboSets = {};
4038 462 DoorComboSetNames = {};
4039 462 }
4040
4041
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 457 times.
463 if(Header->zelda_version > 0x192)
4042 {
4043 //section version info
4044
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
4045 {
4046 return qe_invalid;
4047 }
4048
4049 457 FFCore.quest_format[vDoors] = s_version;
4050
4051
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy_word,f))
4052 {
4053 return qe_invalid;
4054 }
4055
4056 //section size
4057
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy_long,f))
4058 {
4059 return qe_invalid;
4060 }
4061 457 }
4062
4063 //finally... section data
4064
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!p_igetw(&temp_door_combo_set_count,f))
4065 {
4066 return qe_invalid;
4067 }
4068
4069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4070 {
4071 return qe_invalid;
4072 }
4073
4074
2/2
✓ Branch 0 taken 5369 times.
✓ Branch 1 taken 463 times.
5832 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4075 {
4076 5369 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4077
4078 //name
4079 char name[21];
4080
1/2
✓ Branch 0 taken 5369 times.
✗ Branch 1 not taken.
5369 if(!pfread(&name,sizeof(name),f))
4081 {
4082 return qe_invalid;
4083 }
4084
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5355 times.
5369 if (!should_skip)
4085 5355 DoorComboSetNames[i] = name;
4086
4087
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4088 {
4089
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4090 {
4091 return qe_invalid;
4092 }
4093 40 }
4094
4095 //up door
4096
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4097 {
4098
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4099 {
4100
1/2
✓ Branch 0 taken 193284 times.
✗ Branch 1 not taken.
193284 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4101 {
4102 return qe_invalid;
4103 }
4104 193284 }
4105 48321 }
4106
4107
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4108 {
4109
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4110 {
4111
1/2
✓ Branch 0 taken 193284 times.
✗ Branch 1 not taken.
193284 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4112 {
4113 return qe_invalid;
4114 }
4115 193284 }
4116 48321 }
4117
4118 //down door
4119
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4120 {
4121
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4122 {
4123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193284 times.
193284 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4124 {
4125 return qe_invalid;
4126 }
4127 193284 }
4128 48321 }
4129
4130
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4131 {
4132
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4133 {
4134
1/2
✓ Branch 0 taken 193284 times.
✗ Branch 1 not taken.
193284 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4135 {
4136 return qe_invalid;
4137 }
4138 193284 }
4139 48321 }
4140
4141 //left door
4142
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4143 {
4144
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4145 {
4146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289926 times.
289926 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4147 {
4148 return qe_invalid;
4149 }
4150 289926 }
4151 48321 }
4152
4153
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4154 {
4155
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4156 {
4157
1/2
✓ Branch 0 taken 289926 times.
✗ Branch 1 not taken.
289926 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4158 {
4159 return qe_invalid;
4160 }
4161 289926 }
4162 48321 }
4163
4164 //right door
4165
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4166 {
4167
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4168 {
4169
1/2
✓ Branch 0 taken 289926 times.
✗ Branch 1 not taken.
289926 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4170 {
4171 return qe_invalid;
4172 }
4173 289926 }
4174 48321 }
4175
4176
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4177 {
4178
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4179 {
4180
1/2
✓ Branch 0 taken 289926 times.
✗ Branch 1 not taken.
289926 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4181 {
4182 return qe_invalid;
4183 }
4184 289926 }
4185 48321 }
4186
4187 //up bomb rubble
4188
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4189 {
4190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4191 {
4192 return qe_invalid;
4193 }
4194 10738 }
4195
4196
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4197 {
4198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4199 {
4200 return qe_invalid;
4201 }
4202 10738 }
4203
4204 //down bomb rubble
4205
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4206 {
4207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4208 {
4209 return qe_invalid;
4210 }
4211 10738 }
4212
4213
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4214 {
4215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4216 {
4217 return qe_invalid;
4218 }
4219 10738 }
4220
4221 //left bomb rubble
4222
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4223 {
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4225 {
4226 return qe_invalid;
4227 }
4228 16107 }
4229
4230
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4231 {
4232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4233 {
4234 return qe_invalid;
4235 }
4236 16107 }
4237
4238
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4239 {
4240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4241 {
4242 return qe_invalid;
4243 }
4244
4245 40 }
4246
4247 //right bomb rubble
4248
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4249 {
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4251 {
4252 return qe_invalid;
4253 }
4254 16107 }
4255
4256
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4257 {
4258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4259 {
4260 return qe_invalid;
4261 }
4262 16107 }
4263
4264
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4265 {
4266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4267 {
4268 return qe_invalid;
4269 }
4270 40 }
4271
4272 //walkthrough stuff
4273
2/2
✓ Branch 0 taken 21476 times.
✓ Branch 1 taken 5369 times.
26845 for(int32_t j=0; j<4; j++)
4274 {
4275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21476 times.
21476 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4276 {
4277 return qe_invalid;
4278 }
4279 21476 }
4280
4281
2/2
✓ Branch 0 taken 21476 times.
✓ Branch 1 taken 5369 times.
26845 for(int32_t j=0; j<4; j++)
4282 {
4283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21476 times.
21476 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4284 {
4285 return qe_invalid;
4286 }
4287 21476 }
4288
4289 //flags
4290
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4291 {
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_getc(&tempDoorComboSet.flags[j],f))
4293 {
4294 return qe_invalid;
4295 }
4296 10738 }
4297
4298
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4299 {
4300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4301 {
4302 return qe_invalid;
4303 }
4304 40 }
4305
4306
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5355 times.
5369 if (!should_skip)
4307 5355 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4308 5369 }
4309
4310
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 462 times.
463 if (!should_skip)
4311 462 door_combo_set_count=temp_door_combo_set_count;
4312
4313 463 return 0;
4314 481 }
4315
4316 9 int32_t count_dmaps()
4317 {
4318 9 int32_t i=MAXDMAPS-1;
4319 9 bool found=false;
4320
4321
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4322 {
4323
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4324
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4325
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4326 18 found=true;
4327
4328
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4329 {
4330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4331
4332 found=true;
4333 72 }
4334
4335
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4336 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4337 27 found=true;
4338
4339
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4340
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4341
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4342
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4343 18 found=true;
4344
4345 if(!found)
4346 {
4347 i--;
4348 }
4349 }
4350
4351 9 return i+1;
4352 }
4353
4354
4355 9 int32_t count_shops(miscQdata *Misc)
4356 {
4357 9 int32_t i=NUM_SHOPS-1,j;
4358 9 bool found=false;
4359
4360
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4361 {
4362 2229 j=2;
4363
4364
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4365 {
4366
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4367 {
4368 5 found=true;
4369 5 }
4370 else
4371 {
4372 6672 j--;
4373 }
4374 }
4375
4376
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4377 {
4378 found=true;
4379 }
4380
4381
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4382 {
4383 2224 i--;
4384 2224 }
4385 }
4386
4387 9 return i+1;
4388 }
4389
4390 9 int32_t count_infos(miscQdata *Misc)
4391 {
4392 9 int32_t i=255,j;
4393 9 bool found=false;
4394
4395
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4396 {
4397 2229 j=2;
4398
4399
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4400 {
4401
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4402 {
4403 5 found=true;
4404 5 }
4405 else
4406 {
4407 6672 j--;
4408 }
4409 }
4410
4411
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4412 {
4413 found=true;
4414 }
4415
4416
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4417 {
4418 2224 i--;
4419 2224 }
4420 }
4421
4422 9 return i+1;
4423 }
4424
4425 9 int32_t count_warprings(miscQdata *Misc)
4426 {
4427 9 int32_t i=15,j;
4428 9 bool found=false;
4429
4430
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4431 {
4432 49 j=7;
4433
4434
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4435 {
4436
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4437 {
4438 9 found=true;
4439 9 }
4440 else
4441 {
4442 349 j--;
4443 }
4444 }
4445
4446
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4447 {
4448 40 i--;
4449 40 }
4450 }
4451
4452 9 return i+1;
4453 }
4454
4455 9 int32_t count_palcycles(miscQdata *Misc)
4456 {
4457 9 int32_t i=255,j;
4458 9 bool found=false;
4459
4460
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4461 {
4462 2036 j=2;
4463
4464
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4465 {
4466
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4467 {
4468 7 found=true;
4469 7 }
4470 else
4471 {
4472 6087 j--;
4473 }
4474 }
4475
4476
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4477 {
4478 2029 i--;
4479 2029 }
4480 }
4481
4482 9 return i+1;
4483 }
4484
4485 18088 void clear_screen(mapscr *temp_scr)
4486 {
4487 18088 temp_scr->zero_memory();
4488 18088 }
4489
4490 // NOTE: when modifying this, you need to also update:
4491 // readonedmap, readdmaps, and FFScript::read_dmaps
4492 // (and their associated write functions)
4493 3553 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4494 {
4495
2/2
✓ Branch 0 taken 3529 times.
✓ Branch 1 taken 24 times.
3553 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4496
4497 3553 word dmapstoread=0;
4498 3553 dmap tempDMap;
4499
4500 int32_t dummy;
4501 3553 word s_version=0;
4502 byte padding;
4503
4504 char legacy_title[22];
4505
4506
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 480 times.
3553 if (!should_skip)
4507
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<max_dmaps; i++)
4508 {
4509
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 DMaps[start_dmap + i].clear();
4510 245760 sprintf(legacy_title," ");
4511 245760 sprintf(DMaps[start_dmap+i].intro," ");
4512 245760 DMaps[start_dmap+i].type |= dmCAVE;
4513 246240 }
4514
4515
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
3553 if (!should_skip && s_version == 21)
4516 Regions = {};
4517
4518 3553 Header->is_z3 = false;
4519
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 457 times.
✓ Branch 3 taken 24 times.
3553 if(!Header || Header->zelda_version > 0x192)
4520 {
4521 //section version info
4522
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
3529 if(!p_igetw(&s_version,f))
4523 {
4524 return qe_invalid;
4525 }
4526 457 Header->is_z3 = s_version >= 22;
4527
4528 457 FFCore.quest_format[vDMaps] = s_version;
4529
4530
4531
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
4532 {
4533 return qe_invalid;
4534 }
4535
4536 //section size
4537
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
4538 {
4539 return qe_invalid;
4540 }
4541
4542 //finally... section data
4543
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dmapstoread,f))
4544 {
4545 return qe_invalid;
4546 }
4547 457 }
4548 else
4549 {
4550
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4551
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4552 {
4553 18 dmapstoread=32;
4554 18 }
4555
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4556 {
4557 6 dmapstoread=OLDMAXDMAPS;
4558 6 }
4559 else
4560 {
4561 dmapstoread=MAXDMAPS;
4562 }
4563 }
4564
4565
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 398 times.
481 dmapstoread=zc_min(dmapstoread, max_dmaps);
4566
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 398 times.
481 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4567
4568
2/2
✓ Branch 0 taken 220992 times.
✓ Branch 1 taken 481 times.
221473 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4569 {
4570
1/2
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
220992 tempDMap.clear();
4571 220992 sprintf(legacy_title," ");
4572 220992 sprintf(tempDMap.intro," ");
4573
4574
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.map,f))
4575 {
4576 return qe_invalid;
4577 }
4578
4579
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 203776 times.
220992 if(s_version <= 4)
4580 {
4581 byte tempbyte;
4582
4583
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4584 {
4585 return qe_invalid;
4586 }
4587
4588 17216 tempDMap.level=(word)tempbyte;
4589 17216 }
4590 else
4591 {
4592
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetw(&tempDMap.level,f))
4593 {
4594 return qe_invalid;
4595 }
4596 }
4597
4598
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.xoff,f))
4599 {
4600 return qe_invalid;
4601 }
4602
4603
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.compass,f))
4604 {
4605 return qe_invalid;
4606 }
4607
4608
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version > 8) // February 2009
4609 {
4610
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetw(&tempDMap.color,f))
4611 {
4612 return qe_invalid;
4613 }
4614 203776 }
4615 else
4616 {
4617 byte tempbyte;
4618
4619
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4620 {
4621 return qe_invalid;
4622 }
4623
4624 17216 tempDMap.color = (word)tempbyte;
4625 }
4626
4627
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.midi,f))
4628 {
4629 return qe_invalid;
4630 }
4631
4632
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.cont,f))
4633 {
4634 return qe_invalid;
4635 }
4636
4637
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.type,f))
4638 {
4639 return qe_invalid;
4640 }
4641
4642
4/4
✓ Branch 0 taken 5931 times.
✓ Branch 1 taken 215061 times.
✓ Branch 2 taken 5887 times.
✓ Branch 3 taken 44 times.
226923 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4643
1/2
✓ Branch 0 taken 5931 times.
✗ Branch 1 not taken.
5931 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4644 5887 tempDMap.xoff = 0;
4645
4646
2/2
✓ Branch 0 taken 220992 times.
✓ Branch 1 taken 1767936 times.
1988928 for(int32_t j=0; j<8; j++)
4647 {
4648
2/4
✓ Branch 0 taken 1767936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1767936 times.
✗ Branch 3 not taken.
1767936 if(!p_getc(&tempDMap.grid[j],f))
4649 {
4650 return qe_invalid;
4651 }
4652 1767936 }
4653
4654
5/6
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 218880 times.
220992 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4655 {
4656
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4657 {
4658 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4659 127 }
4660
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4661
4662
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4663 {
4664
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4665
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4666 18 }
4667
4668 //forgotten -DD
4669
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4670 {
4671 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4672 439 }
4673 576 }
4674 else
4675 {
4676
3/4
✓ Branch 0 taken 220416 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
218880 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4677 {
4678 return qe_invalid;
4679 }
4680
4681
2/2
✓ Branch 0 taken 127744 times.
✓ Branch 1 taken 92672 times.
220416 if(s_version<20)
4682 {
4683
2/4
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127744 times.
✗ Branch 3 not taken.
127744 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4684 {
4685 return qe_invalid;
4686 }
4687
1/2
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
127744 tempDMap.title.assign(legacy_title);
4688 127744 }
4689 else
4690 {
4691
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_getwstr(&tempDMap.title, f))
4692 {
4693 return qe_invalid;
4694 }
4695 }
4696
4697
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4698 {
4699 return qe_invalid;
4700 }
4701
4702
5/8
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 218880 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
220416 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4703 {
4704 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4705 DMaps[i] = tempDMap;
4706
4707 continue;
4708 }
4709
4710
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4711 {
4712
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4713 {
4714 return qe_invalid;
4715 }
4716 1536 }
4717
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4718 {
4719
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4720 {
4721 return qe_invalid;
4722 }
4723 101376 }
4724 else
4725 {
4726
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4727 {
4728 return qe_invalid;
4729 }
4730 }
4731
4732
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.minimap_cset[0],f))
4733 {
4734 return qe_invalid;
4735 }
4736
4737
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4738 {
4739
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4740 {
4741 return qe_invalid;
4742 }
4743 1536 }
4744
4745
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4746 {
4747
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4748 {
4749 return qe_invalid;
4750 }
4751 101376 }
4752 else
4753 {
4754
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4755 {
4756 return qe_invalid;
4757 }
4758 }
4759
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.minimap_cset[1],f))
4760 {
4761 return qe_invalid;
4762 }
4763
4764
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4765 {
4766
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4767 {
4768 return qe_invalid;
4769 }
4770 1536 }
4771
4772
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4773 {
4774
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4775 {
4776 return qe_invalid;
4777 }
4778 101376 }
4779 else
4780 {
4781
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4782 {
4783 return qe_invalid;
4784 }
4785 }
4786
4787
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.largemap_cset[0],f))
4788 {
4789 return qe_invalid;
4790 }
4791
4792
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4793 {
4794
4795
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4796 {
4797 return qe_invalid;
4798 }
4799 1536 }
4800
4801
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4802 {
4803
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4804 {
4805 return qe_invalid;
4806 }
4807 101376 }
4808 else
4809 {
4810
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4811 {
4812 return qe_invalid;
4813 }
4814 }
4815
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.largemap_cset[1],f))
4816 {
4817 return qe_invalid;
4818 }
4819
4820
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4821 {
4822 return qe_invalid;
4823 }
4824 }
4825
4826
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version>1)
4827 {
4828
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.tmusictrack,f))
4829 {
4830 return qe_invalid;
4831 }
4832
4833
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.active_subscreen,f))
4834 {
4835 return qe_invalid;
4836 }
4837
4838
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.passive_subscreen,f))
4839 {
4840 return qe_invalid;
4841 }
4842 203776 }
4843
4844
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version>2)
4845 {
4846 byte di[32];
4847
4848
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!pfread(&di, 32, f)) return qe_invalid;
4849
4850
2/2
✓ Branch 0 taken 52166656 times.
✓ Branch 1 taken 203776 times.
52370432 for(int32_t j=0; j<MAXITEMS; j++)
4851 {
4852
2/2
✓ Branch 0 taken 52157449 times.
✓ Branch 1 taken 9207 times.
52166656 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4853 52157449 else tempDMap.disableditems[j]=0;
4854 52166656 }
4855 203776 }
4856
4857
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version >= 6)
4858 {
4859
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetl(&tempDMap.flags,f))
4860 {
4861 return qe_invalid;
4862 }
4863 203776 }
4864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4865 {
4866 char temp;
4867
4868 if(!p_getc(&temp,f))
4869 {
4870 return qe_invalid;
4871 }
4872
4873 tempDMap.flags = temp;
4874 }
4875
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4876 {
4877 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4878 8992 }
4879 else
4880 8224 tempDMap.flags=0;
4881
4882
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version<7)
4883 {
4884
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4885 6146 tempDMap.flags|= dmfVIEWMAP;
4886 17216 }
4887
4888
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version<8)
4889 {
4890
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4891 {
4892
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4893 8050 tempDMap.type |= dmCAVE;
4894 8050 }
4895
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4896 {
4897 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4898 2332 }
4899 17216 }
4900
4901
7/8
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 218880 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 218880 times.
220992 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4902 220416 && (Header->zelda_version < 0x193))
4903 {
4904
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4905 {
4906 return qe_invalid;
4907 }
4908 1536 }
4909
4910
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 101376 times.
220992 if(s_version >= 10)
4911 {
4912
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_getc(&tempDMap.sideview,f))
4913 {
4914 return qe_invalid;
4915 }
4916 101376 }
4917
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version < 10) tempDMap.sideview = 0;
4918
4919 //Dmap Scripts
4920
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 12)
4921 {
4922
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.script,f))
4923 {
4924 return qe_invalid;
4925 }
4926
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
4927 {
4928
2/4
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811008 times.
✗ Branch 3 not taken.
811008 if(!p_igetl(&tempDMap.initD[q],f))
4929 {
4930 return qe_invalid;
4931 }
4932 811008 }
4933 101376 }
4934
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if ( s_version < 12 )
4935 {
4936 119616 tempDMap.script = 0;
4937
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4938 {
4939 956928 tempDMap.initD[q] = 0;
4940 956928 }
4941 119616 }
4942
4943
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 101376 times.
220992 if(s_version >= 13)
4944 {
4945
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
4946 {
4947
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; w++ )
4948 {
4949
2/4
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52715520 times.
✗ Branch 3 not taken.
52715520 if(!p_getc(&tempDMap.initD_label[q][w],f))
4950 {
4951 return qe_invalid;
4952 }
4953 52715520 }
4954 811008 }
4955 101376 }
4956
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if ( s_version < 13 )
4957 {
4958 119616 tempDMap.script = 0;
4959
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4960 {
4961
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for ( int32_t w = 0; w < 65; w++ )
4962 62200320 tempDMap.initD_label[q][w] = 0;
4963 956928 }
4964 119616 }
4965
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 14)
4966 {
4967
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.active_sub_script,f))
4968 {
4969 return qe_invalid;
4970 }
4971
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.passive_sub_script,f))
4972 {
4973 return qe_invalid;
4974 }
4975
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; ++q )
4976 {
4977
2/4
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811008 times.
✗ Branch 3 not taken.
811008 if(!p_igetl(&tempDMap.sub_initD[q],f))
4978 {
4979 return qe_invalid;
4980 }
4981 811008 }
4982
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for(int32_t q = 0; q < 8; ++q)
4983 {
4984
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; ++w )
4985 {
4986
2/4
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52715520 times.
✗ Branch 3 not taken.
52715520 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4987 {
4988 return qe_invalid;
4989 }
4990 52715520 }
4991 811008 }
4992 101376 }
4993 else
4994 {
4995 119616 tempDMap.active_sub_script = 0;
4996 119616 tempDMap.passive_sub_script = 0;
4997
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
4998 {
4999 956928 tempDMap.sub_initD[q] = 0;
5000
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5001 62200320 tempDMap.sub_initD_label[q][w] = 0;
5002 956928 }
5003 }
5004
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 15)
5005 {
5006
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.onmap_script,f))
5007 {
5008 return qe_invalid;
5009 }
5010
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; ++q )
5011 {
5012
2/4
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811008 times.
✗ Branch 3 not taken.
811008 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5013 {
5014 return qe_invalid;
5015 }
5016 811008 }
5017
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for(int32_t q = 0; q < 8; ++q)
5018 {
5019
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; ++w )
5020 {
5021
2/4
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52715520 times.
✗ Branch 3 not taken.
52715520 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5022 {
5023 return qe_invalid;
5024 }
5025 52715520 }
5026 811008 }
5027 101376 }
5028 else
5029 {
5030 119616 tempDMap.onmap_script = 0;
5031
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
5032 {
5033 956928 tempDMap.onmap_initD[q] = 0;
5034
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5035 {
5036 62200320 tempDMap.onmap_initD_label[q][w] = 0;
5037 62200320 }
5038 956928 }
5039 }
5040
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 16)
5041 {
5042
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.mirrorDMap,f))
5043 {
5044 return qe_invalid;
5045 }
5046 101376 }
5047 else
5048 {
5049 119616 tempDMap.mirrorDMap = -1;
5050 }
5051
5052 // Enhanced music loop points
5053
2/2
✓ Branch 0 taken 92672 times.
✓ Branch 1 taken 128320 times.
220992 if (s_version >= 18)
5054 {
5055
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5056 {
5057 return qe_invalid;
5058 }
5059
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5060 {
5061 return qe_invalid;
5062 }
5063
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5064 {
5065 return qe_invalid;
5066 }
5067
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5068 {
5069 return qe_invalid;
5070 }
5071 92672 }
5072 else
5073 {
5074 128320 tempDMap.tmusic_loop_start = 0;
5075 128320 tempDMap.tmusic_loop_end = 0;
5076 128320 tempDMap.tmusic_xfade_in = 0;
5077 128320 tempDMap.tmusic_xfade_out = 0;
5078 }
5079
5080
2/2
✓ Branch 0 taken 92672 times.
✓ Branch 1 taken 128320 times.
220992 if(s_version >= 19)
5081
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if(!p_getc(&tempDMap.overlay_subscreen, f))
5082 return qe_invalid;
5083
5084
2/2
✓ Branch 0 taken 92672 times.
✓ Branch 1 taken 128320 times.
220992 if (s_version >= 20)
5085 {
5086
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.intro_string_id, f))
5087 return qe_invalid;
5088 92672 }
5089 else
5090 128320 tempDMap.intro_string_id = 0;
5091
5092
2/2
✓ Branch 0 taken 206656 times.
✓ Branch 1 taken 14336 times.
220992 if(s_version == 21)
5093 {
5094 static regions_data tmp_rd;
5095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5096
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
5097 {
5098
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
5099 {
5100
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
5101 {
5102 return qe_invalid;
5103 }
5104 917504 }
5105 114688 }
5106 14336 }
5107
5108
3/4
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 182080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38912 times.
220992 if (s_version > 22 && (tempDMap.flags & dmfCUSTOM_GRAVITY))
5109 {
5110 if (!p_igetzf(&tempDMap.dmap_gravity, f))
5111 return qe_invalid;
5112 if (!p_igetzf(&tempDMap.dmap_terminal_v, f))
5113 return qe_invalid;
5114 }
5115
5116
2/2
✓ Branch 0 taken 220736 times.
✓ Branch 1 taken 256 times.
220992 if (!should_skip)
5117 {
5118
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 if(loading_tileset_flags & TILESET_CLEARMAPS)
5119 tempDMap.map = 0;
5120
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5121 {
5122 tempDMap.script = 0;
5123 for(int q = 0; q < 8; ++q)
5124 tempDMap.initD[q] = 0;
5125 }
5126
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 DMaps[i] = tempDMap;
5127 220736 }
5128 220992 }
5129
5130 481 return 0;
5131 6625 }
5132
5133 398 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5134 {
5135 //these are here to bypass compiler warnings about unused arguments
5136 398 Header=Header;
5137
5138 miscQdata temp_misc;
5139 398 word s_version=0;
5140 398 int32_t tempsize=0;
5141 word dummyw;
5142
5143 398 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5144
5145 //section version info
5146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
5147 {
5148 return qe_invalid;
5149 }
5150
5151 398 FFCore.quest_format[vColours] = s_version;
5152
5153 398 al_trace("Misc Colours section version: %d\n", s_version);
5154
5155
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
5156 {
5157 return qe_invalid;
5158 }
5159
5160
5161 //section size
5162
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&tempsize,f))
5163 {
5164 return qe_invalid;
5165 }
5166
5167 //finally... section data
5168 398 readsize=0;
5169
5170
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.text,f))
5171 {
5172 return qe_invalid;
5173 }
5174
5175
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.caption,f))
5176 {
5177 return qe_invalid;
5178 }
5179
5180
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.overw_bg,f))
5181 {
5182 return qe_invalid;
5183 }
5184
5185
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5186 {
5187 return qe_invalid;
5188 }
5189
5190
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5191 {
5192 return qe_invalid;
5193 }
5194
5195
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.cave_fg,f))
5196 {
5197 return qe_invalid;
5198 }
5199
5200
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bs_dk,f))
5201 {
5202 return qe_invalid;
5203 }
5204
5205
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bs_goal,f))
5206 {
5207 return qe_invalid;
5208 }
5209
5210
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.compass_lt,f))
5211 {
5212 return qe_invalid;
5213 }
5214
5215
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.compass_dk,f))
5216 {
5217 return qe_invalid;
5218 }
5219
5220
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5221 {
5222 return qe_invalid;
5223 }
5224
5225
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triframe_color,f))
5226 {
5227 return qe_invalid;
5228 }
5229
5230
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.hero_dot,f))
5231 {
5232 return qe_invalid;
5233 }
5234
5235
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5236 {
5237 return qe_invalid;
5238 }
5239
5240
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5241 {
5242 return qe_invalid;
5243 }
5244
5245
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5246 {
5247 return qe_invalid;
5248 }
5249
5250
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5251 {
5252 return qe_invalid;
5253 }
5254
5255
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5256 {
5257 return qe_invalid;
5258 }
5259
5260
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5266 {
5267 return qe_invalid;
5268 }
5269
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version < 4)
5270 {
5271
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5272 return qe_invalid;
5273 200 temp_misc.colors.triforce_tile = dummyw;
5274
5275
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5276 return qe_invalid;
5277 200 temp_misc.colors.triframe_tile = dummyw;
5278
5279
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5280 return qe_invalid;
5281 200 temp_misc.colors.overworld_map_tile = dummyw;
5282
5283
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5284 return qe_invalid;
5285 200 temp_misc.colors.dungeon_map_tile = dummyw;
5286
5287
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5288 return qe_invalid;
5289 200 temp_misc.colors.blueframe_tile = dummyw;
5290
5291
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5292 return qe_invalid;
5293 200 temp_misc.colors.HCpieces_tile = dummyw;
5294 200 }
5295
5296
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5297 {
5298 return qe_invalid;
5299 }
5300
5301
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5302 {
5303 return qe_invalid;
5304 }
5305
5306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version < 2)
5307 {
5308 temp_misc.colors.msgtext = 0x01;
5309 }
5310 else
5311 {
5312
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.msgtext, f))
5313 {
5314 return qe_invalid;
5315 }
5316 }
5317
5318
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if ( s_version >= 3 ) //expanded tile pages to 825
5319 {
5320
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5321 {
5322 return qe_invalid;
5323 }
5324
5325
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5326 {
5327 return qe_invalid;
5328 }
5329
5330
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5331 {
5332 return qe_invalid;
5333 }
5334
5335
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5346 {
5347 return qe_invalid;
5348 }
5349 198 }
5350
5351 398 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5352
5353 398 return 0;
5354 398 }
5355
5356 398 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5357 {
5358 miscQdata temp_misc;
5359 398 word s_version=0;
5360 byte icons;
5361 398 int32_t tempsize=0;
5362
5363 398 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5364
5365 //section version info
5366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
5367 {
5368 return qe_invalid;
5369 }
5370
5371 398 FFCore.quest_format[vIcons] = s_version;
5372
5373
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
5374 {
5375 return qe_invalid;
5376 }
5377
5378
5379 //section size
5380
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&tempsize,f))
5381 {
5382 return qe_invalid;
5383 }
5384
5385 //finally... section data
5386 398 readsize=0;
5387
5388 398 icons=4;
5389
5390
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if ( s_version >= 10 )
5391 {
5392
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<icons; i++)
5393 {
5394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&temp_misc.icons[i],f))
5395 {
5396 return qe_invalid;
5397 }
5398 792 }
5399 198 }
5400 else
5401 {
5402
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<icons; i++)
5403 {
5404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_igetw(&temp_misc.icons[i],f))
5405 {
5406 return qe_invalid;
5407 }
5408 800 }
5409 }
5410
5411 398 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5412
5413 398 return 0;
5414 398 }
5415
5416 804 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5417 {
5418
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5419
5420 804 word maxinfos=256;
5421 804 word maxshops=256;
5422 804 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5423 804 word ponds=16, pondsize=72, expansionsize=98*2;
5424 byte tempbyte, padding;
5425 miscQdata temp_misc;
5426 804 word s_version=0;
5427 word swaptmp;
5428 804 int32_t tempsize=0;
5429
5430 804 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5431
5432
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxshops; ++i)
5433 {
5434 205824 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5435 205824 }
5436
5437
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxinfos; ++i)
5438 {
5439 205824 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5440 205824 }
5441
5442 804 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5443
5444
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5445 {
5446 //section version info
5447
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&s_version,f))
5448 {
5449 return qe_invalid;
5450 }
5451
5452 780 FFCore.quest_format[vMisc] = s_version;
5453
5454
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!read_deprecated_section_cversion(f))
5455 {
5456 return qe_invalid;
5457 }
5458
5459
5460 //section size
5461
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&tempsize,f))
5462 {
5463 return qe_invalid;
5464 }
5465 780 }
5466
5467 //finally... section data
5468 804 readsize=0;
5469
5470 //shops
5471
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5472 {
5473
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&shops,f))
5474 {
5475 return qe_invalid;
5476 }
5477 780 }
5478
5479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (shops > NUM_SHOPS)
5480 {
5481 return qe_invalid;
5482 }
5483
5484
2/2
✓ Branch 0 taken 11102 times.
✓ Branch 1 taken 804 times.
11906 for(int32_t i=0; i<shops; i++)
5485 {
5486
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9902 times.
11102 if(s_version > 6)
5487 {
5488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9902 times.
9902 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5489 {
5490 return qe_invalid;
5491 }
5492 9902 }
5493
5494
2/2
✓ Branch 0 taken 33306 times.
✓ Branch 1 taken 11102 times.
44408 for(int32_t j=0; j<3; j++)
5495 {
5496
1/2
✓ Branch 0 taken 33306 times.
✗ Branch 1 not taken.
33306 if(!p_getc(&temp_misc.shop[i].item[j],f))
5497 {
5498 return qe_invalid;
5499 }
5500
5501
2/2
✓ Branch 0 taken 29706 times.
✓ Branch 1 taken 3600 times.
33306 if(s_version < 4)
5502 {
5503 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5504 3600 }
5505 33306 }
5506
5507
2/2
✓ Branch 0 taken 10718 times.
✓ Branch 1 taken 384 times.
11102 if(Header->zelda_version < 0x193)
5508 {
5509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5510 {
5511 return qe_invalid;
5512 }
5513 384 }
5514
5515
2/2
✓ Branch 0 taken 33306 times.
✓ Branch 1 taken 11102 times.
44408 for(int32_t j=0; j<3; j++)
5516 {
5517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33306 times.
33306 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5518 {
5519 return qe_invalid;
5520 }
5521 33306 }
5522
5523
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9902 times.
11102 if(s_version > 3)
5524 {
5525
2/2
✓ Branch 0 taken 29706 times.
✓ Branch 1 taken 9902 times.
39608 for(int32_t j=0; j<3; j++)
5526 {
5527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29706 times.
29706 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5528 return qe_invalid;
5529 29706 }
5530 9902 }
5531
5532 /*
5533 if(s_version < 8)
5534 {
5535 for(int32_t j=0; j<3; j++)
5536 {
5537 (&temp_misc.shop[i].str[j])=0; //initialise.
5538 }
5539 }
5540 */
5541 11102 }
5542
5543 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5544
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxshops; ++i)
5545 {
5546
2/2
✓ Branch 0 taken 411648 times.
✓ Branch 1 taken 205824 times.
617472 for(int32_t j=0; j<3-1; j++)
5547 {
5548
2/2
✓ Branch 0 taken 617472 times.
✓ Branch 1 taken 411648 times.
1029120 for(int32_t k=0; k<2-j; k++)
5549 {
5550
2/2
✓ Branch 0 taken 23937 times.
✓ Branch 1 taken 593535 times.
617472 if(temp_misc.shop[i].hasitem[k]==0)
5551 {
5552 593535 swaptmp = temp_misc.shop[i].item[k];
5553 593535 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5554 593535 temp_misc.shop[i].item[k+1] = swaptmp;
5555 593535 swaptmp = temp_misc.shop[i].price[k];
5556 593535 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5557 593535 temp_misc.shop[i].price[k+1] = swaptmp;
5558 593535 swaptmp = temp_misc.shop[i].hasitem[k];
5559 593535 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5560 593535 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5561 593535 }
5562 617472 }
5563 411648 }
5564 205824 }
5565
5566 //infos
5567
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5568 {
5569
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&infos,f))
5570 {
5571 return qe_invalid;
5572 }
5573 780 }
5574
5575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (infos > NUM_INFOS)
5576 {
5577 return qe_invalid;
5578 }
5579
5580
5581
2/2
✓ Branch 0 taken 10408 times.
✓ Branch 1 taken 804 times.
11212 for(int32_t i=0; i<infos; i++)
5582 {
5583
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9647 times.
10408 if(s_version > 6)
5584 {
5585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647 times.
9647 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5586 {
5587 return qe_invalid;
5588 }
5589 9647 }
5590
5591
2/2
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 10408 times.
41632 for(int32_t j=0; j<3; j++)
5592 {
5593
3/4
✓ Branch 0 taken 30360 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
31512 if((Header->zelda_version < 0x192)||
5594
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 30072 times.
30360 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5595 {
5596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5597 {
5598 return qe_invalid;
5599 }
5600
5601 864 temp_misc.info[i].str[j]=tempbyte;
5602 864 }
5603 else
5604 {
5605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30360 times.
30360 if(!p_igetw(&temp_misc.info[i].str[j],f))
5606 {
5607 return qe_invalid;
5608 }
5609 }
5610 31224 }
5611
5612
2/2
✓ Branch 0 taken 10024 times.
✓ Branch 1 taken 384 times.
10408 if(Header->zelda_version < 0x193)
5613 {
5614
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5615 {
5616 return qe_invalid;
5617 }
5618 384 }
5619
5620
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10408 if((Header->zelda_version == 0x192)&&(Header->build>145))
5621 {
5622
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5623 {
5624 return qe_invalid;
5625 }
5626 96 }
5627
5628
2/2
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 10408 times.
41632 for(int32_t j=0; j<3; j++)
5629 {
5630
1/2
✓ Branch 0 taken 31224 times.
✗ Branch 1 not taken.
31224 if(!p_igetw(&temp_misc.info[i].price[j],f))
5631 {
5632 return qe_invalid;
5633 }
5634 31224 }
5635 10408 }
5636
5637 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5638
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxinfos; ++i)
5639 {
5640
2/2
✓ Branch 0 taken 411648 times.
✓ Branch 1 taken 205824 times.
617472 for(int32_t j=0; j<3-1; j++)
5641 {
5642
2/2
✓ Branch 0 taken 617472 times.
✓ Branch 1 taken 411648 times.
1029120 for(int32_t k=0; k<2-j; k++)
5643 {
5644
2/2
✓ Branch 0 taken 11788 times.
✓ Branch 1 taken 605684 times.
617472 if(temp_misc.info[i].str[k]==0)
5645 {
5646 605684 swaptmp = temp_misc.info[i].str[k];
5647 605684 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5648 605684 temp_misc.info[i].str[k+1] = swaptmp;
5649 605684 swaptmp = temp_misc.info[i].price[k];
5650 605684 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5651 605684 temp_misc.info[i].price[k+1] = swaptmp;
5652 605684 }
5653 617472 }
5654 411648 }
5655 205824 }
5656
5657
5658 //warp rings
5659
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 721 times.
804 if(s_version > 5)
5660 721 warprings++;
5661
5662
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5663 {
5664
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&warprings,f))
5665 {
5666 return qe_invalid;
5667 }
5668
5669
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 440 times.
780 if (warprings > NUM_WARP_RINGS)
5670 {
5671 // return qe_invalid;
5672 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5673 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5674 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5675 440 }
5676 780 }
5677
5678
2/2
✓ Branch 0 taken 8404 times.
✓ Branch 1 taken 804 times.
9208 for(int32_t i=0; i<warprings; i++)
5679 {
5680 // See above comment on the `warprings` range check.
5681 8404 bool keepdata = i < NUM_WARP_RINGS;
5682
5683
2/2
✓ Branch 0 taken 74516 times.
✓ Branch 1 taken 8404 times.
82920 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5684 {
5685
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 65556 times.
74516 if(s_version <= 3)
5686 {
5687
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5688 {
5689 return qe_invalid;
5690 }
5691
5692
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5693 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5694 8960 }
5695 else
5696 {
5697 word tempword;
5698
1/2
✓ Branch 0 taken 65556 times.
✗ Branch 1 not taken.
65556 if(!p_igetw(&tempword,f))
5699 {
5700 return qe_invalid;
5701 }
5702
5703
2/2
✓ Branch 0 taken 7461 times.
✓ Branch 1 taken 58095 times.
65556 if (keepdata)
5704 58095 temp_misc.warp[i].dmap[j] = tempword;
5705 }
5706 74516 }
5707
5708
2/2
✓ Branch 0 taken 74516 times.
✓ Branch 1 taken 8404 times.
82920 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5709 {
5710
1/2
✓ Branch 0 taken 74516 times.
✗ Branch 1 not taken.
74516 if(!p_getc(&tempbyte,f))
5711 {
5712 return qe_invalid;
5713 }
5714
2/2
✓ Branch 0 taken 10653 times.
✓ Branch 1 taken 63863 times.
74516 if (keepdata)
5715 63863 temp_misc.warp[i].scr[j] = tempbyte;
5716 74516 }
5717
5718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8404 times.
8404 if(!p_getc(&tempbyte,f))
5719 {
5720 return qe_invalid;
5721 }
5722
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 7176 times.
8404 if (keepdata)
5723 7176 temp_misc.warp[i].size = tempbyte;
5724
5725
2/2
✓ Branch 0 taken 8212 times.
✓ Branch 1 taken 192 times.
8404 if(Header->zelda_version < 0x193)
5726 {
5727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5728 {
5729 return qe_invalid;
5730 }
5731 192 }
5732 8404 }
5733
5734 //palette cycles
5735
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5736 {
5737
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5738 {
5739
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5740 {
5741 18432 temp_misc.cycles[i][j].first=0;
5742 18432 temp_misc.cycles[i][j].count=0;
5743 18432 temp_misc.cycles[i][j].speed=0;
5744 18432 }
5745 6144 }
5746
5747
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5748
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5749 {
5750 18 palcycles=16;
5751 18 }
5752
5753
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5754 {
5755
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5756 {
5757
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5758 {
5759 return qe_invalid;
5760 }
5761
5762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5763 {
5764 return qe_invalid;
5765 }
5766
5767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5768 {
5769 return qe_invalid;
5770 }
5771 5472 }
5772 1824 }
5773 24 }
5774
5775 //Wind warps are now just another warp ring.
5776
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
804 if(s_version <= 5)
5777 {
5778
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5779 {
5780
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5781 {
5782 return qe_invalid;
5783 }
5784 59 }
5785
5786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5787 {
5788 return qe_invalid;
5789 }
5790
5791
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5792 {
5793
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5794 {
5795
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5796 {
5797 return qe_invalid;
5798 }
5799
5800 665 temp_misc.warp[8].dmap[i]=tempbyte;
5801 665 }
5802 else
5803 {
5804 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5805 {
5806 return qe_invalid;
5807 }
5808 }
5809
5810
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5811 {
5812 return qe_invalid;
5813 }
5814
5815 665 temp_misc.warp[8].size = 9;
5816
5817
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5818 {
5819 if(!p_getc(&tempbyte,f))
5820 {
5821 return qe_invalid;
5822 }
5823 }
5824 665 }
5825 83 }
5826
5827
5828 //triforce pieces
5829
2/2
✓ Branch 0 taken 6432 times.
✓ Branch 1 taken 804 times.
7236 for(int32_t i=0; i<triforces; i++)
5830 {
5831
1/2
✓ Branch 0 taken 6432 times.
✗ Branch 1 not taken.
6432 if(!p_getc(&temp_misc.triforce[i],f))
5832 {
5833 return qe_invalid;
5834 }
5835 6432 }
5836
5837 //misc color data
5838
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
804 if(s_version<3)
5839 {
5840
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5841 {
5842 return qe_invalid;
5843 }
5844
5845
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5846 {
5847 return qe_invalid;
5848 }
5849
5850
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5851 {
5852 return qe_invalid;
5853 }
5854
5855
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5856 {
5857 return qe_invalid;
5858 }
5859
5860
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5861 {
5862 return qe_invalid;
5863 }
5864
5865
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5866 {
5867 return qe_invalid;
5868 }
5869
5870
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5871 {
5872 return qe_invalid;
5873 }
5874
5875
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5876 {
5877 return qe_invalid;
5878 }
5879
5880
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5881 {
5882 return qe_invalid;
5883 }
5884
5885
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5886 {
5887 return qe_invalid;
5888 }
5889
5890
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5891 {
5892 return qe_invalid;
5893 }
5894
5895
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5896 {
5897 return qe_invalid;
5898 }
5899
5900
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5901 {
5902 return qe_invalid;
5903 }
5904
5905
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5906 {
5907 return qe_invalid;
5908 }
5909
5910
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5911 {
5912 return qe_invalid;
5913 }
5914
5915
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5916 {
5917 return qe_invalid;
5918 }
5919
5920
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5921 {
5922 return qe_invalid;
5923 }
5924
5925
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5926 {
5927 return qe_invalid;
5928 }
5929
5930
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5931 {
5932 return qe_invalid;
5933 }
5934
5935
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5936 {
5937 return qe_invalid;
5938 }
5939
5940
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5941 {
5942 return qe_invalid;
5943 }
5944
5945
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5946 {
5947 return qe_invalid;
5948 }
5949
5950
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5951 {
5952 return qe_invalid;
5953 }
5954
5955
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5956 {
5957 return qe_invalid;
5958 }
5959
5960
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5961 {
5962 return qe_invalid;
5963 }
5964
5965
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5966 {
5967 return qe_invalid;
5968 }
5969
5970
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5971 {
5972 return qe_invalid;
5973 }
5974
5975 83 temp_misc.colors.msgtext = 0x01;
5976
5977
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5978 {
5979
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5980 {
5981
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5982 {
5983 return qe_invalid;
5984 }
5985 168 }
5986 24 }
5987
5988
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5989 {
5990
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
5991 {
5992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
5993 {
5994 return qe_invalid;
5995 }
5996 1536 }
5997 6 }
5998
5999
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
6000 {
6001 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6002 {
6003 return qe_invalid;
6004 }
6005 }
6006
6007 //save game icons
6008
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6009
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6010 {
6011 18 icons=3;
6012 18 }
6013
6014
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6015 {
6016
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6017 {
6018 return qe_invalid;
6019 }
6020 314 }
6021 83 }
6022
6023
3/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
810 if((Header->zelda_version < 0x192)||
6024
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 780 times.
786 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6025 {
6026 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6027
6028 18 return 0;
6029 }
6030
6031 //pond information
6032
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 6 times.
786 if(Header->zelda_version < 0x193)
6033 {
6034
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6035 {
6036 pondsize=25;
6037 }
6038
6039
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6040 {
6041
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6042 {
6043
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6044 {
6045 return qe_invalid;
6046
6047 }
6048 6912 }
6049 96 }
6050 6 }
6051
6052 //end string
6053
2/4
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
792 if((Header->zelda_version < 0x192)||
6054
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 780 times.
786 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6055 {
6056 if(!p_getc(&tempbyte,f))
6057 {
6058 return qe_invalid;
6059 }
6060
6061 temp_misc.endstring=tempbyte;
6062
6063 if(!p_getc(&tempbyte,f))
6064 {
6065 return qe_invalid;
6066 }
6067 }
6068 else
6069 {
6070
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(!p_igetw(&temp_misc.endstring,f))
6071 {
6072 return qe_invalid;
6073 }
6074 }
6075
6076 //expansion
6077
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 6 times.
786 if(Header->zelda_version < 0x193)
6078 {
6079
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6080 {
6081 expansionsize=99*2;
6082 }
6083
6084
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6085 {
6086
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6087 {
6088 return qe_invalid;
6089 }
6090 1176 }
6091 6 }
6092 //shops v8
6093
6094
6095
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 198 times.
786 if(s_version >= 8)
6096 {
6097
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 198 times.
2614 for(int32_t i=0; i<shops; i++)
6098 {
6099
2/2
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 2416 times.
9664 for(int32_t j=0; j<3; j++)
6100 {
6101
1/2
✓ Branch 0 taken 7248 times.
✗ Branch 1 not taken.
7248 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6102 return qe_invalid;
6103 7248 }
6104 2416 }
6105 198 }
6106
6107 786 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6108 786 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6109
6110 //v9 includes quest misc[32]
6111 // ... this has been deprecated (2024)
6112
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 198 times.
786 if(s_version >= 9)
6113 {
6114
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 198 times.
6534 for ( int32_t q = 0; q < 32; q++ )
6115 {
6116
1/2
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
6336 if(!p_igetl(&temp_misc.questmisc[q],f))
6117 return qe_invalid;
6118 6336 }
6119 // this was string labels
6120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if (pack_fseek(f, 32 * 128))
6121 return qe_invalid;
6122 198 }
6123
6124
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 11 )
6125 {
6126
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6127 return qe_invalid;
6128 198 }
6129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 else if(s_version < 11 )
6130 {
6131 588 temp_misc.zscript_last_compiled_version = -1;
6132 588 }
6133
6134 786 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6135
6136
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 12)
6137 {
6138 byte spr;
6139
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t q = 0; q < sprMAX; ++q)
6140 {
6141
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&spr,f))
6142 return qe_invalid;
6143 50688 temp_misc.sprites[q] = spr;
6144 50688 }
6145 198 }
6146 else
6147 {
6148 588 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6149 //temp_misc.sprites[sprFALL] = ;
6150 }
6151
6152
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 13)
6153 {
6154
2/2
✓ Branch 0 taken 12672 times.
✓ Branch 1 taken 198 times.
12870 for(size_t q = 0; q < 64; ++q)
6155 {
6156 12672 bottletype* bt = &(temp_misc.bottle_types[q]);
6157
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6158 return qe_invalid;
6159
2/2
✓ Branch 0 taken 38016 times.
✓ Branch 1 taken 12672 times.
50688 for(size_t j = 0; j < 3; ++j)
6160 {
6161
1/2
✓ Branch 0 taken 38016 times.
✗ Branch 1 not taken.
38016 if (!p_getc(&(bt->counter[j]), f))
6162 return qe_invalid;
6163
1/2
✓ Branch 0 taken 38016 times.
✗ Branch 1 not taken.
38016 if (!p_igetw(&(bt->amount[j]), f))
6164 return qe_invalid;
6165 38016 }
6166
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if (!p_getc(&(bt->flags), f))
6167 return qe_invalid;
6168
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if (!p_getc(&(bt->next_type), f))
6169 return qe_invalid;
6170 12672 }
6171
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(size_t q = 0; q < 256; ++q)
6172 {
6173 50688 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6174
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6175 return qe_invalid;
6176
2/2
✓ Branch 0 taken 152064 times.
✓ Branch 1 taken 50688 times.
202752 for(size_t j = 0; j < 3; ++j)
6177 {
6178
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_getc(&(bst->fill[j]), f))
6179 return qe_invalid;
6180
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_igetw(&(bst->comb[j]), f))
6181 return qe_invalid;
6182
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_getc(&(bst->cset[j]), f))
6183 return qe_invalid;
6184
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_igetw(&(bst->price[j]), f))
6185 return qe_invalid;
6186
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_igetw(&(bst->str[j]), f))
6187 return qe_invalid;
6188 152064 }
6189 50688 }
6190 198 }
6191 else
6192 {
6193
2/2
✓ Branch 0 taken 37632 times.
✓ Branch 1 taken 588 times.
38220 for(size_t q = 0; q < 64; ++q)
6194 37632 temp_misc.bottle_types[q].clear();
6195
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(size_t q = 0; q < 256; ++q)
6196 150528 temp_misc.bottle_shop_types[q].clear();
6197 }
6198
6199
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 14)
6200 {
6201 byte msfx;
6202
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t q = 0; q < sfxMAX; ++q)
6203 {
6204
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&msfx,f))
6205 return qe_invalid;
6206 50688 temp_misc.miscsfx[q] = msfx;
6207 50688 }
6208 198 }
6209 else
6210 {
6211 588 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6212 588 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6213 588 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6214 }
6215
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version < 15)
6216 {
6217 588 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6218 588 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6219 588 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6220 588 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6221 588 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6222 588 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6223 588 }
6224
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 605 times.
786 if(s_version < 16)
6225 {
6226 605 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6227 605 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6228 605 }
6229
6230
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 785 times.
786 if (!should_skip)
6231 785 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6232
6233 786 return 0;
6234 804 }
6235
6236 extern char *item_string[MAXITEMS];
6237 extern const char *old_item_string[iLast];
6238 extern char *weapon_string[MAXWPNS];
6239 extern const char *old_weapon_string[wLast];
6240
6241 481 int32_t readitems(PACKFILE *f, word version, word build)
6242 {
6243
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6244
6245 byte padding;
6246 int32_t dummy;
6247 481 word items_to_read=MAXITEMS;
6248 481 itemdata tempitem;
6249 481 word s_version=0;
6250 word dummy_word;
6251
6252
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(version < 0x186)
6253 {
6254 6 items_to_read=64;
6255 6 }
6256
6257
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(version > 0x192)
6258 {
6259 457 items_to_read=0;
6260
6261 //section version info
6262
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
6263 {
6264 return qe_invalid;
6265 }
6266
6267 457 FFCore.quest_format[vItems] = s_version;
6268
6269
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!read_deprecated_section_cversion(f))
6270 {
6271 return qe_invalid;
6272 }
6273
6274 //section size
6275
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
6276 {
6277 return qe_invalid;
6278 }
6279
6280 //finally... section data
6281
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&items_to_read,f))
6282 {
6283 return qe_invalid;
6284 }
6285
6286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (items_to_read > MAXITEMS)
6287 {
6288 return qe_invalid;
6289 }
6290 457 }
6291
6292
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 83 times.
481 if(s_version>1)
6293 {
6294
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i=0; i<items_to_read; i++)
6295 {
6296 char tempname[64];
6297
6298
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!pfread(tempname, 64, f))
6299 {
6300 return qe_invalid;
6301 }
6302
6303 101888 item_string[i][0] = '\0';
6304 101888 strncat(item_string[i], tempname, 64 - 1);
6305 101888 }
6306 398 }
6307
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6308 {
6309
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6310 {
6311 20992 reset_itemname(i);
6312 20992 }
6313 82 }
6314
6315
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
6316
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMS; i++)
6317 {
6318 122880 itemdata& id = itemsbuf[i];
6319 122880 memset(&id, 0, sizeof(itemdata));
6320 122880 id.count=-1;
6321 122880 id.playsound=WAV_SCALE;
6322 122880 reset_itembuf(&id,i);
6323 123360 }
6324
6325
2/2
✓ Branch 0 taken 111010 times.
✓ Branch 1 taken 481 times.
111491 for(int32_t i=0; i<items_to_read; i++)
6326 {
6327 111010 tempitem = itemdata();
6328 111010 reset_itembuf(&tempitem,i);
6329
6330
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 60322 times.
111010 if ( s_version > 35 ) //expanded tiles
6331 {
6332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.tile,f))
6333 {
6334 return qe_invalid;
6335 }
6336 50688 }
6337 else
6338 {
6339
1/2
✓ Branch 0 taken 60322 times.
✗ Branch 1 not taken.
60322 if(!p_igetw(&tempitem.tile,f))
6340 {
6341 return qe_invalid;
6342 }
6343 }
6344
6345
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.misc_flags,f))
6346 {
6347 return qe_invalid;
6348 }
6349
6350
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.csets,f))
6351 {
6352 return qe_invalid;
6353 }
6354
6355
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.frames,f))
6356 {
6357 return qe_invalid;
6358 }
6359
6360
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.speed,f))
6361 {
6362 return qe_invalid;
6363 }
6364
6365
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.delay,f))
6366 {
6367 return qe_invalid;
6368 }
6369
6370
2/2
✓ Branch 0 taken 106018 times.
✓ Branch 1 taken 4992 times.
111010 if(version < 0x193)
6371 {
6372
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6373 {
6374 return qe_invalid;
6375 }
6376
6377
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6378 {
6379
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6380 256 continue;
6381
6382
3/3
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4690 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6383 {
6384 case iShield:
6385 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6386 23 break;
6387
6388 case iMShield:
6389 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6390 23 break;
6391
6392 default:
6393 4690 tempitem.ltm=0;
6394 4690 break;
6395 }
6396
6397 4736 tempitem.count=-1;
6398 4736 tempitem.flags=item_none;
6399 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6400 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6401 4736 tempitem.type=0xFF;
6402 4736 tempitem.playsound=WAV_SCALE;
6403 4736 reset_itembuf(&tempitem,i);
6404
6405 4736 itemsbuf[i] = tempitem;
6406
6407 4736 continue;
6408 }
6409 }
6410
6411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106018 times.
106018 if(!p_igetl(&tempitem.ltm,f))
6412 {
6413 return qe_invalid;
6414 }
6415
6416
1/2
✓ Branch 0 taken 106018 times.
✗ Branch 1 not taken.
106018 if(version < 0x193)
6417 {
6418 for(int32_t q=0; q<12; q++)
6419 {
6420 if(!p_getc(&padding,f))
6421 {
6422 return qe_invalid;
6423 }
6424 }
6425 }
6426
6427
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 4130 times.
106018 if(s_version>1)
6428 {
6429
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
101888 if ( s_version >= 31 )
6430 {
6431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.type,f))
6432 {
6433 return qe_invalid;
6434 }
6435 50688 }
6436 else
6437 {
6438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.type,f))
6439 {
6440 return qe_invalid;
6441 }
6442 }
6443
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version < 16)
6444 if(tempitem.type == 0xFF)
6445 tempitem.type = itype_misc;
6446
6447
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.level,f))
6448 {
6449 return qe_invalid;
6450 }
6451
6452
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version>5)
6453 {
6454
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
101888 if(s_version>=31)
6455 {
6456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.power,f))
6457 {
6458 return qe_invalid;
6459 }
6460 50688 }
6461 else
6462 {
6463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.power,f))
6464 {
6465 return qe_invalid;
6466 }
6467 }
6468
6469 //converted flags from 16b to 32b -Z
6470
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version < 41 )
6471 {
6472
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempitem.flags,f))
6473 {
6474 return qe_invalid;
6475 }
6476 51200 }
6477 else
6478 {
6479
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.flags,f))
6480 {
6481 return qe_invalid;
6482 }
6483 }
6484 101888 }
6485 else
6486 {
6487 //tempitem.power = tempitem.fam_type;
6488 char tempchar;
6489
6490 if(!p_getc(&tempchar,f))
6491 {
6492 return qe_invalid;
6493 }
6494
6495 if (tempchar) tempitem.flags |= item_gamedata;
6496 }
6497
6498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.script,f))
6499 {
6500 return qe_invalid;
6501 }
6502
6503
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<=3)
6504 {
6505 if(tempitem.script > NUMSCRIPTITEM)
6506 {
6507 tempitem.script = 0;
6508 }
6509 }
6510
6511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.count,f))
6512 {
6513 return qe_invalid;
6514 }
6515
6516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.amount,f))
6517 {
6518 return qe_invalid;
6519 }
6520
6521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.collect_script,f))
6522 {
6523 return qe_invalid;
6524 }
6525
6526
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<=3)
6527 {
6528 if(tempitem.collect_script > NUMSCRIPTITEM)
6529 {
6530 tempitem.collect_script = 0;
6531 }
6532 }
6533
6534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.setmax,f))
6535 {
6536 return qe_invalid;
6537 }
6538
6539
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetw(&tempitem.max,f))
6540 {
6541 return qe_invalid;
6542 }
6543
6544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.playsound,f))
6545 {
6546 return qe_invalid;
6547 }
6548
6549
2/2
✓ Branch 0 taken 815104 times.
✓ Branch 1 taken 101888 times.
916992 for(int32_t j=0; j<8; j++)
6550 {
6551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 815104 times.
815104 if(!p_igetl(&tempitem.initiald[j],f))
6552 {
6553 return qe_invalid;
6554 }
6555 815104 }
6556
6557
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 101888 times.
305664 for(int32_t j=0; j<2; j++)
6558 {
6559 byte temp;
6560
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&temp,f))
6561 {
6562 return qe_invalid;
6563 }
6564 203776 }
6565
6566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>4)
6567 {
6568
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version>5)
6569 {
6570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn,f))
6571 {
6572 return qe_invalid;
6573 }
6574
6575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn2,f))
6576 {
6577 return qe_invalid;
6578 }
6579
6580
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn3,f))
6581 {
6582 return qe_invalid;
6583 }
6584
6585
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn4,f))
6586 {
6587 return qe_invalid;
6588 }
6589
6590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>=15)
6591 {
6592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn5,f))
6593 {
6594 return qe_invalid;
6595 }
6596
6597
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn6,f))
6598 {
6599 return qe_invalid;
6600 }
6601
6602
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn7,f))
6603 {
6604 return qe_invalid;
6605 }
6606
6607
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn8,f))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn9,f))
6613 {
6614 return qe_invalid;
6615 }
6616
6617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn10,f))
6618 {
6619 return qe_invalid;
6620 }
6621 101888 }
6622
6623
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.pickup_hearts,f))
6624 {
6625 return qe_invalid;
6626 }
6627
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version<15)
6629 {
6630 if(!p_igetw(&dummy_word,f))
6631 {
6632 return qe_invalid;
6633 }
6634
6635 tempitem.misc1=dummy_word;
6636
6637 if(!p_igetw(&dummy_word,f))
6638 {
6639 return qe_invalid;
6640 }
6641
6642 tempitem.misc2=dummy_word;
6643 }
6644 else
6645 {
6646
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc1,f))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc2,f))
6652 {
6653 return qe_invalid;
6654 }
6655
6656 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6657
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<24)
6658 {
6659 if(tempitem.type==itype_shield)
6660 {
6661 tempitem.misc1|=sh_script;
6662 }
6663 }
6664 }
6665
6666
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if(s_version < 53)
6667 {
6668 byte tempbyte;
6669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempbyte,f))
6670 {
6671 return qe_invalid;
6672 }
6673 51200 tempitem.cost_amount[0] = tempbyte;
6674 51200 }
6675 else
6676 {
6677
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for(auto q = 0; q < 2; ++q)
6678 {
6679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101376 times.
101376 if(!p_igetw(&tempitem.cost_amount[q],f))
6680 {
6681 return qe_invalid;
6682 }
6683 101376 }
6684 }
6685 101888 }
6686 else
6687 {
6688 char tempchar;
6689
6690 if(!p_getc(&tempchar,f))
6691 {
6692 return qe_invalid;
6693 }
6694
6695 if (tempchar) tempitem.flags |= item_edible;
6696 }
6697
6698 // June 2007: more misc. attributes
6699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>=12)
6700 {
6701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version<15)
6702 {
6703 if(!p_igetw(&dummy_word,f))
6704 {
6705 return qe_invalid;
6706 }
6707
6708 tempitem.misc3=dummy_word;
6709
6710 if(!p_igetw(&dummy_word,f))
6711 {
6712 return qe_invalid;
6713 }
6714
6715 tempitem.misc4=dummy_word;
6716 }
6717 else
6718 {
6719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc3,f))
6720 {
6721 return qe_invalid;
6722 }
6723
6724
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc4,f))
6725 {
6726 return qe_invalid;
6727 }
6728
6729
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc5,f))
6730 {
6731 return qe_invalid;
6732 }
6733
6734
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc6,f))
6735 {
6736 return qe_invalid;
6737 }
6738
6739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc7,f))
6740 {
6741 return qe_invalid;
6742 }
6743
6744
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc8,f))
6745 {
6746 return qe_invalid;
6747 }
6748
6749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc9,f))
6750 {
6751 return qe_invalid;
6752 }
6753
6754
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc10,f))
6755 {
6756 return qe_invalid;
6757 }
6758 }
6759
6760
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.usesound,f))
6761 {
6762 return qe_invalid;
6763 }
6764
6765
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
101888 if(s_version >= 49)
6766 {
6767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_getc(&tempitem.usesound2,f))
6768 {
6769 return qe_invalid;
6770 }
6771 50688 }
6772 51200 else tempitem.usesound2 = 0;
6773
6774
3/4
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
✓ Branch 2 taken 51200 times.
✗ Branch 3 not taken.
101888 if(s_version < 50 && tempitem.type == itype_mirror)
6775 {
6776 //Split continue/dmap warp effect/sfx, port for old
6777 tempitem.misc2 = tempitem.misc1;
6778 tempitem.usesound2 = tempitem.usesound;
6779 }
6780 101888 }
6781 101888 }
6782
6783
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6784 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6785
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6786 {
6787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17664 times.
17664 if(!p_getc(&tempitem.weap_data.imitate_weapon,f))
6788 {
6789 return qe_invalid;
6790 }
6791
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_getc(&tempitem.weap_data.default_defense,f))
6792 {
6793 return qe_invalid;
6794 }
6795 17664 }
6796
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.weaprange,f))
6797 {
6798 return qe_invalid;
6799 }
6800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.weapduration,f))
6801 {
6802 return qe_invalid;
6803 }
6804
2/2
✓ Branch 0 taken 506880 times.
✓ Branch 1 taken 50688 times.
557568 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6805 {
6806
1/2
✓ Branch 0 taken 506880 times.
✗ Branch 1 not taken.
506880 if(!p_igetl(&tempitem.weap_pattern[q],f))
6807 {
6808 return qe_invalid;
6809 }
6810 506880 }
6811 50688 }
6812
6813
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6814 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.duplicates,f))
6816 {
6817 return qe_invalid;
6818 }
6819
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6820
2/2
✓ Branch 0 taken 141312 times.
✓ Branch 1 taken 17664 times.
158976 for ( int32_t q = 0; q < INITIAL_D; q++ )
6821
1/2
✓ Branch 0 taken 141312 times.
✗ Branch 1 not taken.
141312 if(!p_igetl(&tempitem.weap_data.initd[q],f))
6822 17664 return qe_invalid;
6823
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for ( int32_t q = 0; q < 2; q++ )
6824 {
6825 byte temp;
6826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101376 times.
101376 if(!p_getc(&temp,f))
6827 {
6828 return qe_invalid;
6829 }
6830 101376 }
6831
6832
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempitem.drawlayer,f))
6833 {
6834 return qe_invalid;
6835 }
6836
6837
6838
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.hxofs,f))
6839 {
6840 return qe_invalid;
6841 }
6842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.hyofs,f))
6843 {
6844 return qe_invalid;
6845 }
6846
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.hxsz,f))
6847 {
6848 return qe_invalid;
6849 }
6850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.hysz,f))
6851 {
6852 return qe_invalid;
6853 }
6854
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.hzsz,f))
6855 {
6856 return qe_invalid;
6857 }
6858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.xofs,f))
6859 {
6860 return qe_invalid;
6861 }
6862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.yofs,f))
6863 {
6864 return qe_invalid;
6865 }
6866
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6867 {
6868
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hxofs,f))
6869 return qe_invalid;
6870
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hyofs,f))
6871 return qe_invalid;
6872
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hxsz,f))
6873 return qe_invalid;
6874
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hysz,f))
6875 return qe_invalid;
6876
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hzsz,f))
6877 return qe_invalid;
6878
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.xofs,f))
6879 return qe_invalid;
6880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17664 times.
17664 if(!p_igetl(&tempitem.weap_data.yofs,f))
6881 return qe_invalid;
6882 17664 }
6883
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6884
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetw(&tempitem.weap_data.script,f))
6885 return qe_invalid;
6886
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.wpnsprite,f))
6887 {
6888 return qe_invalid;
6889 }
6890 50688 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6891
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for(auto q = 0; q < num_cost_tmr; ++q)
6892 {
6893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101376 times.
101376 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6894 {
6895 return qe_invalid;
6896 }
6897 101376 }
6898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 for(auto q = num_cost_tmr; q < 2; ++q)
6899 tempitem.magiccosttimer[q] = 0;
6900 50688 }
6901
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6902 {
6903 //Item Size FLags, TileWidth, TileHeight
6904
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.overrideFLAGS,f))
6905 {
6906 return qe_invalid;
6907 }
6908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.tilew,f))
6909 {
6910 return qe_invalid;
6911 }
6912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.tileh,f))
6913 {
6914 return qe_invalid;
6915 }
6916 50688 }
6917
4/4
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
✓ Branch 2 taken 33024 times.
✓ Branch 3 taken 17664 times.
101888 if ( s_version >= 29 && s_version < 63) //! More new vars.
6918 {
6919
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.override_flags,f))
6920 return qe_invalid;
6921
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.tilew,f))
6922 return qe_invalid;
6923
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.tileh,f))
6924 return qe_invalid;
6925 17664 }
6926
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 30 ) //! More new vars.
6927 {
6928 //Pickup Type
6929
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.pickup,f))
6930 {
6931 return qe_invalid;
6932 }
6933 50688 }
6934
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 32 ) //! More new vars.
6935 {
6936 //Pickup Type
6937
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempitem.pstring,f))
6938 {
6939 return qe_invalid;
6940 }
6941 50688 }
6942
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 33 ) //! More new vars.
6943 {
6944 //Pickup Type
6945
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempitem.pickup_string_flags,f))
6946 {
6947 return qe_invalid;
6948 }
6949 50688 }
6950
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 34 ) //! cost counter
6951 {
6952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(s_version < 53)
6953 {
6954 if(!p_getc(&tempitem.cost_counter[0],f))
6955 {
6956 return qe_invalid;
6957 }
6958 }
6959 else
6960 {
6961
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for(auto q = 0; q < 2; ++q)
6962 {
6963
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&tempitem.cost_counter[q],f))
6964 {
6965 return qe_invalid;
6966 }
6967 101376 }
6968 }
6969 50688 }
6970
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 44 ) //! sprite scripts
6971 {
6972
2/2
✓ Branch 0 taken 405504 times.
✓ Branch 1 taken 50688 times.
456192 for ( int32_t q = 0; q < 8; q++ )
6973 {
6974
2/2
✓ Branch 0 taken 26357760 times.
✓ Branch 1 taken 405504 times.
26763264 for ( int32_t w = 0; w < 65; w++ )
6975 {
6976
1/2
✓ Branch 0 taken 26357760 times.
✗ Branch 1 not taken.
26357760 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6977 {
6978 return qe_invalid;
6979 }
6980 26357760 }
6981
2/2
✓ Branch 0 taken 264192 times.
✓ Branch 1 taken 141312 times.
405504 if(s_version < 63)
6982
2/2
✓ Branch 0 taken 9185280 times.
✓ Branch 1 taken 141312 times.
9326592 for ( int32_t w = 0; w < 65; w++ )
6983
1/2
✓ Branch 0 taken 9185280 times.
✗ Branch 1 not taken.
9185280 if(!p_getc(&padding,f))
6984 141312 return qe_invalid;
6985
2/2
✓ Branch 0 taken 26357760 times.
✓ Branch 1 taken 405504 times.
26763264 for ( int32_t w = 0; w < 65; w++ )
6986 {
6987
1/2
✓ Branch 0 taken 26357760 times.
✗ Branch 1 not taken.
26357760 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
6988 {
6989 return qe_invalid;
6990 }
6991 26357760 }
6992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405504 times.
405504 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
6993 {
6994 return qe_invalid;
6995 }
6996
6997 405504 }
6998
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for ( int32_t q = 0; q < 2; q++ )
6999 {
7000 byte temp;
7001
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&temp,f))
7002 {
7003 return qe_invalid;
7004 }
7005 101376 }
7006 //Pickup Type
7007
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempitem.sprite_script,f))
7008 {
7009 return qe_invalid;
7010 }
7011 50688 }
7012
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 48 ) //! pickup flags
7013 {
7014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_getc(&(tempitem.pickupflag),f))
7015 {
7016 return qe_invalid;
7017 }
7018 50688 }
7019
2/2
✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 47360 times.
101888 if ( s_version >= 57 )
7020 {
7021 47360 std::string str;
7022
2/4
✓ Branch 0 taken 47360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47360 times.
✗ Branch 3 not taken.
47360 if(!p_getcstr(&str,f))
7023 return qe_invalid;
7024 47360 strncpy(tempitem.display_name,str.c_str(),255);
7025
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 47360 times.
47360 }
7026 101888 }
7027 else
7028 {
7029 4130 tempitem.count=-1;
7030 4130 tempitem.type=itype_misc;
7031 4130 tempitem.flags=item_none;
7032 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7033 4130 tempitem.playsound=WAV_SCALE;
7034 4130 reset_itembuf(&tempitem,i);
7035 }
7036
7037
4/4
✓ Branch 0 taken 46336 times.
✓ Branch 1 taken 59682 times.
✓ Branch 2 taken 33024 times.
✓ Branch 3 taken 13312 times.
106018 if(s_version >= 58 && s_version < 63)
7038 {
7039
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 13312 times.
79872 for(int q = 0; q < WPNSPR_MAX; ++q)
7040 {
7041
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if(!p_getc(&tempitem.weap_data.burnsprs[q],f))
7042 return qe_invalid;
7043
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 65280 times.
66560 if(s_version >= 59)
7044
1/2
✓ Branch 0 taken 65280 times.
✗ Branch 1 not taken.
65280 if(!p_getc(&tempitem.weap_data.light_rads[q],f))
7045 return qe_invalid;
7046 66560 }
7047 13312 }
7048
7049
2/2
✓ Branch 0 taken 71458 times.
✓ Branch 1 taken 34560 times.
106018 if ( s_version >= 60 )
7050 {
7051
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 15104 times.
34560 if ( s_version >= 65 )
7052 {
7053
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&tempitem.pickup_litems,f))
7054 return qe_invalid;
7055 19456 }
7056 else
7057 {
7058
1/2
✓ Branch 0 taken 15104 times.
✗ Branch 1 not taken.
15104 if(!p_getc(&padding,f))
7059 return qe_invalid;
7060 15104 tempitem.pickup_litems = word(padding);
7061 }
7062
1/2
✓ Branch 0 taken 34560 times.
✗ Branch 1 not taken.
34560 if(!p_igetw(&tempitem.pickup_litem_level,f))
7063 return qe_invalid;
7064 34560 }
7065
7066
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 71458 times.
106018 if ( s_version >= 62 )
7067 {
7068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34560 times.
34560 if (!p_igetl(&tempitem.moveflags, f))
7069 return qe_invalid;
7070
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 1536 times.
34560 if(s_version < 63)
7071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if (!p_igetl(&tempitem.weap_data.moveflags, f))
7072 return qe_invalid;
7073 34560 }
7074 else
7075 {
7076 71458 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
7077
3/3
✓ Branch 0 taken 2050 times.
✓ Branch 1 taken 69089 times.
✓ Branch 2 taken 319 times.
71458 switch(tempitem.type)
7078 {
7079 case itype_divinefire:
7080
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 134 times.
319 if(!(tempitem.flags & item_flag3))
7081 134 break;
7082 [[fallthrough]];
7083 case itype_bomb: case itype_sbomb:
7084 case itype_bait: case itype_liftglove:
7085 case itype_candle: case itype_book:
7086 2235 tempitem.weap_data.moveflags = (move_obeys_grav | move_can_pitfall);
7087 2235 break;
7088 default:
7089 69089 tempitem.weap_data.moveflags = move_none;
7090 69089 break;
7091 }
7092 }
7093
7094
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 72994 times.
106018 if(s_version >= 63)
7095 {
7096
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(auto ret = read_weap_data(tempitem.weap_data, f))
7097 return ret;
7098 33024 }
7099 else
7100 {
7101
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 72977 times.
72994 SETFLAG(tempitem.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempitem.flags & item_burning_sprites);
7102
3/3
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 72246 times.
✓ Branch 2 taken 82 times.
72994 switch(tempitem.type)
7103 {
7104 case itype_liftglove:
7105 82 tempitem.weap_data.wflags = WFLAG_BREAK_WHEN_LANDING;
7106 82 break;
7107 case itype_bomb: case itype_sbomb:
7108 // Moving these over and removing them from itemdata
7109
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 23 times.
666 if(tempitem.flags & item_flag3)
7110 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_LANDING;
7111
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 23 times.
666 if(tempitem.flags & item_flag5)
7112 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_HIT_SOLID;
7113 666 tempitem.flags &= ~(item_flag3|item_flag5);
7114
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 17 times.
666 if(tempitem.misc4)
7115 {
7116 17 tempitem.weap_data.lift_level = tempitem.misc4;
7117 17 tempitem.weap_data.lift_time = tempitem.misc5;
7118 17 tempitem.weap_data.lift_height = tempitem.misc6;
7119 17 tempitem.misc4 = 0;
7120 17 tempitem.misc5 = 0;
7121 17 tempitem.misc6 = 0;
7122 17 }
7123 666 break;
7124 }
7125 }
7126
7127
2/2
✓ Branch 0 taken 86562 times.
✓ Branch 1 taken 19456 times.
106018 if (s_version >= 64)
7128 {
7129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if (!p_igetl(&tempitem.cooldown, f))
7130 return qe_invalid;
7131 19456 }
7132
7133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106018 times.
106018 if (!should_skip)
7134 {
7135
1/2
✓ Branch 0 taken 106018 times.
✗ Branch 1 not taken.
106018 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7136 {
7137 tempitem.script = 0;
7138 tempitem.weap_data.script = 0;
7139 for(int q = 0; q < 8; ++q)
7140 {
7141 tempitem.initiald[q] = 0;
7142 tempitem.weap_data.initd[q] = 0;
7143 }
7144 }
7145 106018 itemsbuf[i] = tempitem;
7146 106018 }
7147 106018 }
7148
7149
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (should_skip)
7150 1 return 0;
7151
7152 //////////////////////////////////////////////////////
7153 // Now do any updates because of new item additions
7154 // (These can't be done above because items_to_read
7155 // might be too low.)
7156 //////////////////////////////////////////////////////
7157
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMS; i++)
7158 {
7159 122880 tempitem = itemsbuf[i];
7160
7161 //Account for older quests that didn't have an actual item for the used letter
7162
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 2 && i==iLetterUsed)
7163 {
7164 82 reset_itembuf(&tempitem, iLetterUsed);
7165 82 strcpy(item_string[i],old_item_string[i]);
7166 82 tempitem.tile = itemsbuf[iLetter].tile;
7167 82 tempitem.csets = itemsbuf[iLetter].csets;
7168 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7169 82 tempitem.frames = itemsbuf[iLetter].frames;
7170 82 tempitem.speed = itemsbuf[iLetter].speed;
7171 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7172 82 }
7173
7174
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 3)
7175 {
7176
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7177 {
7178 case iRocsFeather:
7179 case iHoverBoots:
7180 case iSpinScroll:
7181 case iL2SpinScroll:
7182 case iCrossScroll:
7183 case iQuakeScroll:
7184 case iL2QuakeScroll:
7185 case iWhispRing:
7186 case iL2WhispRing:
7187 case iChargeRing:
7188 case iL2ChargeRing:
7189 case iPerilScroll:
7190 case iWalletL3:
7191 case iQuiverL4:
7192 case iBombBagL4:
7193 case iBracelet:
7194 case iL2Bracelet:
7195 case iOldGlove:
7196 case iL2Ladder:
7197 case iWealthMedal:
7198 case iL2WealthMedal:
7199 case iL3WealthMedal:
7200 1804 reset_itembuf(&tempitem, i);
7201 1804 strcpy(item_string[i],old_item_string[i]);
7202 1804 break;
7203
7204 case iSShield:
7205 82 reset_itembuf(&tempitem, i);
7206 82 strcpy(item_string[i],old_item_string[i]);
7207 82 strcpy(item_string[iShield],old_item_string[iShield]);
7208 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7209 82 break;
7210 }
7211 20992 }
7212
7213
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 5)
7214 {
7215
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7216 {
7217 case iHeartRing:
7218 case iL2HeartRing:
7219 case iL3HeartRing:
7220 case iMagicRing:
7221 case iL2MagicRing:
7222 case iL3MagicRing:
7223 case iL4MagicRing:
7224 574 reset_itembuf(&tempitem, i);
7225 574 strcpy(item_string[i],old_item_string[i]);
7226 574 break;
7227 }
7228 20992 }
7229
7230
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7231 {
7232
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7233
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7234
7235
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 328 times.
✓ Branch 11 taken 17302 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7236 {
7237 case iTriforce:
7238 82 tempitem.level=1;
7239 82 break;
7240
7241 case iBigTri:
7242 82 tempitem.level=0;
7243 82 break;
7244
7245 case iBombs:
7246 82 tempitem.level=i_bomb;
7247 82 tempitem.power=4;
7248 82 tempitem.wpn=wBOMB;
7249 82 tempitem.wpn2=wBOOM;
7250 82 tempitem.misc1 = 50;
7251
7252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7253
7254 82 break;
7255
7256 case iSBomb:
7257 82 tempitem.level=i_sbomb;
7258 82 tempitem.power=16;
7259 82 tempitem.wpn=wSBOMB;
7260 82 tempitem.wpn2=wSBOOM;
7261 82 tempitem.misc1 = 50;
7262
7263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7264
7265 82 break;
7266
7267 case iBook:
7268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7269 tempitem.wpn = wFIREMAGIC;
7270
7271 82 break;
7272
7273 case iSArrow:
7274 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7275 82 tempitem.power=4;
7276 82 tempitem.flags|=item_gamedata;
7277 82 tempitem.wpn=wSARROW;
7278 82 break;
7279
7280 case iGArrow:
7281 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7282 82 tempitem.power=8;
7283 82 tempitem.flags|=(item_gamedata|item_flag1);
7284 82 tempitem.wpn=wGARROW;
7285 82 break;
7286
7287 case iBrang:
7288 82 tempitem.power=0;
7289 82 tempitem.wpn=wBRANG;
7290 82 tempitem.misc1=36;
7291 82 break;
7292
7293 case iMBrang:
7294 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7295 82 tempitem.power=0;
7296 82 tempitem.wpn=wMBRANG;
7297 82 break;
7298
7299 case iFBrang:
7300 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7301 82 tempitem.power=2;
7302 82 tempitem.wpn=wFBRANG;
7303 82 break;
7304
7305 case iBoots:
7306 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7307 82 tempitem.power=7;
7308 82 break;
7309
7310 case iWand:
7311 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7312 82 tempitem.power=2;
7313 82 tempitem.wpn=wWAND;
7314 82 tempitem.wpn3=wMAGIC;
7315 82 break;
7316
7317 case iBCandle:
7318 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7319 82 tempitem.power=1;
7320 82 tempitem.flags|=(item_gamedata|item_flag1);
7321 82 tempitem.wpn3=wFIRE;
7322 82 break;
7323
7324 case iRCandle:
7325 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7326 82 tempitem.power=1;
7327 82 tempitem.wpn3=wFIRE;
7328 82 break;
7329
7330 case iSword:
7331 82 tempitem.power=1;
7332 82 tempitem.flags|= item_flag4 |item_flag2;
7333 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7334 82 tempitem.wpn2=wSWORDSLASH;
7335 82 break;
7336
7337 case iWSword:
7338 82 tempitem.power=2;
7339 82 tempitem.flags|= item_flag4 |item_flag2;
7340 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7341 82 tempitem.wpn2=wWSWORDSLASH;
7342 82 break;
7343
7344 case iMSword:
7345 82 tempitem.power=4;
7346 82 tempitem.flags|= item_flag4 |item_flag2;
7347 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7348 82 tempitem.wpn2=wMSWORDSLASH;
7349 82 break;
7350
7351 case iXSword:
7352 82 tempitem.power=8;
7353 82 tempitem.flags|= item_flag4 |item_flag2;
7354 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7355 82 tempitem.wpn2=wXSWORDSLASH;
7356 82 break;
7357
7358 case iDivineProtection:
7359 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7360 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7361 82 tempitem.wpn=wDIVINEPROTECTION1A;
7362 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7363 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7364 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7365 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7366 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7367 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7368 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7369 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7370 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7371 82 tempitem.misc1=512;
7372 82 tempitem.cost_amount[0]=64;
7373 82 break;
7374
7375 case iLens:
7376 82 tempitem.misc1=60;
7377 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7378 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7379 82 break;
7380
7381 case iArrow:
7382 82 tempitem.power=2;
7383 82 tempitem.wpn=wARROW;
7384 82 break;
7385
7386 case iHoverBoots:
7387 82 tempitem.misc1=45;
7388 82 tempitem.wpn=iwHover;
7389 82 break;
7390
7391 case iDivineFire:
7392 82 tempitem.power=8;
7393 82 tempitem.wpn=wDIVINEFIRE1A;
7394 82 tempitem.wpn2=wDIVINEFIRE1B;
7395 82 tempitem.wpn3=wDIVINEFIRES1A;
7396 82 tempitem.wpn4=wDIVINEFIRES1B;
7397 82 tempitem.misc1 = 32;
7398 82 tempitem.misc2 = 200;
7399 82 tempitem.cost_amount[0]=32;
7400 82 break;
7401
7402 case iDivineEscape:
7403 82 tempitem.cost_amount[0]=32;
7404 82 break;
7405
7406 case iHookshot:
7407 82 tempitem.power=0;
7408 82 tempitem.flags&=~item_flag1;
7409 82 tempitem.wpn=wHSHEAD;
7410 82 tempitem.wpn2=wHSCHAIN_H;
7411 82 tempitem.wpn4=wHSHANDLE;
7412 82 tempitem.wpn3=wHSCHAIN_V;
7413 82 tempitem.misc1=50;
7414 82 tempitem.misc2=100;
7415 82 break;
7416
7417 case iLongshot:
7418 82 tempitem.power=0;
7419 82 tempitem.flags&=~item_flag1;
7420 82 tempitem.wpn=wLSHEAD;
7421 82 tempitem.wpn2=wLSCHAIN_H;
7422 82 tempitem.wpn4=wLSHANDLE;
7423 82 tempitem.wpn3=wLSCHAIN_V;
7424 82 tempitem.misc1=99;
7425 82 tempitem.misc2=100;
7426 82 break;
7427
7428 case iHammer:
7429 82 tempitem.power=4;
7430 82 tempitem.wpn=wHAMMER;
7431 82 tempitem.wpn2=iwHammerSmack;
7432 82 break;
7433
7434 case iCByrna:
7435 82 tempitem.power=1;
7436 82 tempitem.wpn=wCBYRNA;
7437 82 tempitem.wpn2=wCBYRNASLASH;
7438 82 tempitem.wpn3=wCBYRNAORB;
7439 82 tempitem.misc1=4;
7440 82 tempitem.misc2=16;
7441 82 tempitem.misc3=1;
7442 82 tempitem.cost_amount[0]=1;
7443 82 break;
7444
7445 case iWhistle:
7446 82 tempitem.wpn=wWIND;
7447 82 tempitem.misc1=3;
7448 82 tempitem.flags|=item_flag1;
7449 82 break;
7450
7451 case iBRing:
7452 82 tempitem.power=2;
7453 82 tempitem.misc1=spBLUE;
7454 82 break;
7455
7456 case iRRing:
7457 82 tempitem.power=4;
7458 82 tempitem.misc1=spRED;
7459 82 break;
7460
7461 case iGRing:
7462 82 tempitem.power=8;
7463 82 tempitem.misc1=spGOLD;
7464 82 break;
7465
7466 case iSpinScroll:
7467 82 tempitem.power = 2;
7468 82 tempitem.misc1 = 1;
7469 82 break;
7470
7471 case iL2SpinScroll:
7472 82 tempitem.type=itype_spinscroll2;
7473 82 tempitem.level=1;
7474 82 tempitem.cost_amount[0]=8;
7475 82 tempitem.power=2;
7476 82 tempitem.misc1 = 20;
7477 82 break;
7478
7479 case iQuakeScroll:
7480 82 tempitem.misc1=0x10;
7481 82 tempitem.misc2=64;
7482 82 break;
7483
7484 case iL2QuakeScroll:
7485 82 tempitem.type=itype_quakescroll2;
7486 82 tempitem.level=1;
7487 82 tempitem.power = 2;
7488 82 tempitem.misc1=0x20;
7489 82 tempitem.misc2=192;
7490 82 tempitem.cost_amount[0]=8;
7491 82 break;
7492
7493 case iChargeRing:
7494 82 tempitem.misc1=64;
7495 82 tempitem.misc2=128;
7496 82 break;
7497
7498 case iL2ChargeRing:
7499 82 tempitem.misc1=32;
7500 82 tempitem.misc2=64;
7501 82 break;
7502
7503 case iOldGlove:
7504 82 tempitem.flags |= item_flag1;
7505
7506 //fallthrough
7507 case iBombBagL4:
7508 case iWalletL3:
7509 case iQuiverL4:
7510 case iBracelet:
7511 410 tempitem.power = 1;
7512 410 break;
7513
7514 case iL2Bracelet:
7515 82 tempitem.power = 2;
7516 82 break;
7517
7518 case iMKey:
7519 82 tempitem.power=0xFF;
7520 82 tempitem.flags |= item_flag1;
7521 82 break;
7522 }
7523 20992 }
7524
7525
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 7)
7526 {
7527
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7528 {
7529 case iStoneAgony:
7530 case iStompBoots:
7531 case iPerilRing:
7532 case iWhimsicalRing:
7533 {
7534 328 reset_itembuf(&tempitem, i);
7535 328 strcpy(item_string[i],old_item_string[i]);
7536 328 break;
7537 }
7538 }
7539 20992 }
7540
7541
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 8) // May 2007: Some corrections.
7542 {
7543
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7544 {
7545 case iMShield:
7546 82 tempitem.misc1|=sh_flame;
7547 82 tempitem.misc2|=sh_fireball|sh_magic;
7548
7549
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7550 {
7551 tempitem.misc2 |= sh_sword;
7552 }
7553
7554 // fallthrough
7555 case iShield:
7556 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7557
7558 // fallthrough
7559 case iSShield:
7560 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7561
7562
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7563 {
7564 tempitem.misc2 |= sh_rock;
7565 }
7566
7567 246 break;
7568
7569 case iWhispRing:
7570 82 tempitem.power=1;
7571 82 tempitem.flags|=item_gamedata|item_flag1;
7572 82 tempitem.misc1 = 3;
7573 82 break;
7574
7575 case iL2WhispRing:
7576 82 tempitem.power=0;
7577 82 tempitem.flags|=item_gamedata|item_flag1;
7578 82 tempitem.misc1 = 3;
7579 82 break;
7580
7581 case iL2Ladder:
7582 case iBow:
7583 case iCByrna:
7584 246 tempitem.power = 1;
7585 246 break;
7586 }
7587 20992 }
7588
7589
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 9 && i==iClock)
7590 {
7591 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7592 82 }
7593
7594 //add the misc flag for bomb
7595
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 10 && tempitem.type == itype_bomb)
7596 {
7597 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7598 82 }
7599
7600
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
122880 if(s_version < 11 && tempitem.type == itype_triforcepiece)
7601 {
7602 164 tempitem.flags = (tempitem.level ? item_gamedata : item_none);
7603 164 tempitem.playsound = (tempitem.level ? WAV_SCALE : WAV_CLEARED);
7604 164 }
7605
7606
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 12) // June 2007: More Misc. attributes.
7607 {
7608
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7609 {
7610 case iFBrang:
7611 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7612
7613 //fallthrough
7614 case iMBrang:
7615 164 tempitem.misc3 |= sh_sword|sh_magic;
7616
7617 //fallthrough
7618 case iHookshot:
7619 case iLongshot:
7620 //fallthrough
7621 328 tempitem.misc3 |= sh_fireball;
7622
7623 case iBrang:
7624 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7625 410 break;
7626 }
7627
7628
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 246 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 164 times.
✓ Branch 10 taken 9629 times.
✓ Branch 11 taken 164 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.type)
7629 {
7630 case itype_hoverboots:
7631 82 tempitem.usesound = WAV_ZN1HOVER;
7632 82 break;
7633
7634 case itype_wand:
7635 82 tempitem.usesound = WAV_WAND;
7636 82 break;
7637
7638 case itype_book:
7639 82 tempitem.usesound = WAV_FIRE;
7640 82 break;
7641
7642 case itype_arrow:
7643 246 tempitem.usesound = WAV_ARROW;
7644 246 break;
7645
7646 case itype_hookshot:
7647 164 tempitem.usesound = WAV_HOOKSHOT;
7648 164 break;
7649
7650 case itype_brang:
7651 246 tempitem.usesound = WAV_BRANG;
7652 246 break;
7653
7654 case itype_shield:
7655 246 tempitem.usesound = WAV_CHINK;
7656 246 break;
7657
7658 case itype_sword:
7659 9313 tempitem.usesound = WAV_SWORD;
7660 9313 break;
7661
7662 case itype_whistle:
7663 82 tempitem.usesound = WAV_WHISTLE;
7664 82 break;
7665
7666 case itype_hammer:
7667 82 tempitem.usesound = WAV_HAMMER;
7668 82 break;
7669
7670 case itype_divinefire:
7671 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7672 82 break;
7673
7674 case itype_divineescape:
7675 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7676 82 break;
7677
7678 case itype_divineprotection:
7679 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7680 82 break;
7681
7682 case itype_bomb:
7683 case itype_sbomb:
7684 case itype_quakescroll:
7685 case itype_quakescroll2:
7686 328 tempitem.usesound = WAV_BOMB;
7687 328 break;
7688
7689 case itype_spinscroll:
7690 case itype_spinscroll2:
7691 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7692 164 break;
7693 }
7694 20992 }
7695
7696
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 13) // July 2007
7697 {
7698
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7699 {
7700 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7701 82 tempitem.power = 1;
7702 82 tempitem.flags|=item_flag1;
7703 82 }
7704
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_wand)
7705 82 tempitem.flags|=item_flag1;
7706
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.type == itype_book)
7707 {
7708 82 tempitem.flags|=item_flag1;
7709 82 tempitem.power = 2;
7710 82 }
7711 20992 }
7712
7713
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 14) // August 2007
7714 {
7715
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.type == itype_fairy)
7716 {
7717 164 tempitem.usesound = WAV_SCALE;
7718
7719
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.level)
7720 164 tempitem.misc3=50;
7721 164 }
7722
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_potion)
7723 {
7724 164 tempitem.flags |= item_gain_old;
7725 164 }
7726 20992 }
7727
7728
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 17) // November 2007
7729 {
7730
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.type == itype_candle && !tempitem.wpn3)
7731 {
7732 tempitem.wpn3 = wFIRE;
7733 }
7734
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.type == itype_arrow && tempitem.power>4)
7735 {
7736 82 tempitem.flags|=item_flag1;
7737 82 }
7738 20992 }
7739
7740
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 18) // New Year's Eve 2007
7741 {
7742
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7743 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7744
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_bait)
7745 82 tempitem.misc1 = 768; // Frames until it goes
7746
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_triforcepiece)
7747 {
7748
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7749 {
7750 82 tempitem.misc2 = 1; // Cutscene 1
7751 82 tempitem.flags |= item_flag1; // Side Warp Out
7752 82 }
7753 164 }
7754 20992 }
7755
7756
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 19) // January 2008
7757 {
7758
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7759 {
7760
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7761
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7762 82 }
7763 20992 }
7764
7765
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 20) // October 2008
7766 {
7767
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7768 {
7769 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7770 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7771 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7772 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7773 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7774 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7775 82 }
7776 20992 }
7777
7778
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 21) // November 2008
7779 {
7780
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7781 {
7782 tempitem.flags &= ~item_unused;
7783
7784 if(tempitem.type == itype_sword ||
7785 tempitem.type == itype_wand ||
7786 tempitem.type == itype_candle ||
7787 tempitem.type == itype_cbyrna)
7788 {
7789 tempitem.flags |= item_flag4;
7790 }
7791 }
7792 20992 }
7793
7794
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 22) // September 2009
7795 {
7796
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.type == itype_sbomb || tempitem.type == itype_bomb)
7797 {
7798 164 tempitem.misc3 = tempitem.power/2;
7799 164 }
7800 20992 }
7801
7802
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 23) // March 2011
7803 {
7804
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_divinefire)
7805 82 tempitem.wpn5 = wFIRE;
7806
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.type == itype_book)
7807 82 tempitem.wpn2 = wFIRE;
7808 20992 }
7809
7810 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7811 // whether it was or not, and a lot of existing quests depended on the
7812 // incorrect behavior.
7813
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 25) // January 2012
7814 {
7815
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.type == itype_bombbag)
7816 328 tempitem.flags |= item_flag1;
7817
7818
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divinefire)
7819 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7820 20992 }
7821
7822
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7823 {
7824
60/60
✓ Branch 0 taken 17547 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 327 times.
✓ Branch 5 taken 282 times.
✓ Branch 6 taken 558 times.
✓ Branch 7 taken 614 times.
✓ Branch 8 taken 297 times.
✓ Branch 9 taken 917 times.
✓ Branch 10 taken 892 times.
✓ Branch 11 taken 557 times.
✓ Branch 12 taken 858 times.
✓ Branch 13 taken 558 times.
✓ Branch 14 taken 279 times.
✓ Branch 15 taken 558 times.
✓ Branch 16 taken 295 times.
✓ Branch 17 taken 279 times.
✓ Branch 18 taken 846 times.
✓ Branch 19 taken 282 times.
✓ Branch 20 taken 285 times.
✓ Branch 21 taken 560 times.
✓ Branch 22 taken 255 times.
✓ Branch 23 taken 282 times.
✓ Branch 24 taken 279 times.
✓ Branch 25 taken 279 times.
✓ Branch 26 taken 279 times.
✓ Branch 27 taken 295 times.
✓ Branch 28 taken 281 times.
✓ Branch 29 taken 282 times.
✓ Branch 30 taken 279 times.
✓ Branch 31 taken 284 times.
✓ Branch 32 taken 558 times.
✓ Branch 33 taken 1116 times.
✓ Branch 34 taken 780 times.
✓ Branch 35 taken 279 times.
✓ Branch 36 taken 545 times.
✓ Branch 37 taken 1116 times.
✓ Branch 38 taken 279 times.
✓ Branch 39 taken 279 times.
✓ Branch 40 taken 279 times.
✓ Branch 41 taken 279 times.
✓ Branch 42 taken 279 times.
✓ Branch 43 taken 561 times.
✓ Branch 44 taken 558 times.
✓ Branch 45 taken 279 times.
✓ Branch 46 taken 840 times.
✓ Branch 47 taken 843 times.
✓ Branch 48 taken 1128 times.
✓ Branch 49 taken 279 times.
✓ Branch 50 taken 279 times.
✓ Branch 51 taken 279 times.
✓ Branch 52 taken 279 times.
✓ Branch 53 taken 279 times.
✓ Branch 54 taken 306 times.
✓ Branch 55 taken 10652 times.
✓ Branch 56 taken 2872 times.
✓ Branch 57 taken 842 times.
✓ Branch 58 taken 3261 times.
✓ Branch 59 taken 11005 times.
72192 switch(tempitem.type)
7825 {
7826 case itype_sword:
7827 {
7828 17547 tempitem.flags &= ~(item_flag5);
7829 17547 tempitem.misc3 = 0;
7830 17547 tempitem.misc4 = 0;
7831 17547 tempitem.misc5 = 0;
7832 17547 tempitem.misc6 = 0;
7833 17547 tempitem.misc7 = 0;
7834 17547 tempitem.misc8 = 0;
7835 17547 tempitem.misc9 = 0;
7836 17547 tempitem.misc10 = 0;
7837 17547 tempitem.wpn4 = 0;
7838 17547 tempitem.wpn5 = 0;
7839 17547 tempitem.wpn6 = 0;
7840 17547 tempitem.wpn7 = 0;
7841 17547 tempitem.wpn8 = 0;
7842 17547 tempitem.wpn9 = 0;
7843 17547 tempitem.wpn10 = 0;
7844 17547 break;
7845 }
7846 case itype_brang:
7847 {
7848 844 tempitem.flags &= ~(item_flag4 | item_flag5);
7849 844 tempitem.misc2 = 0;
7850 844 tempitem.misc5 = 0;
7851 844 tempitem.misc6 = 0;
7852 844 tempitem.misc7 = 0;
7853 844 tempitem.misc8 = 0;
7854 844 tempitem.misc9 = 0;
7855 844 tempitem.misc10 = 0;
7856 844 tempitem.wpn4 = 0;
7857 844 tempitem.wpn5 = 0;
7858 844 tempitem.wpn6 = 0;
7859 844 tempitem.wpn7 = 0;
7860 844 tempitem.wpn8 = 0;
7861 844 tempitem.wpn9 = 0;
7862 844 tempitem.wpn10 = 0;
7863 844 break;
7864 }
7865 case itype_arrow:
7866 {
7867 831 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7868 831 tempitem.misc2 = 0;
7869 831 tempitem.misc3 = 0;
7870 831 tempitem.misc4 = 0;
7871 831 tempitem.misc5 = 0;
7872 831 tempitem.misc6 = 0;
7873 831 tempitem.misc7 = 0;
7874 831 tempitem.misc8 = 0;
7875 831 tempitem.misc9 = 0;
7876 831 tempitem.misc10 = 0;
7877 831 tempitem.wpn4 = 0;
7878 831 tempitem.wpn5 = 0;
7879 831 tempitem.wpn6 = 0;
7880 831 tempitem.wpn7 = 0;
7881 831 tempitem.wpn8 = 0;
7882 831 tempitem.wpn9 = 0;
7883 831 tempitem.wpn10 = 0;
7884 831 break;
7885 }
7886 case itype_candle:
7887 {
7888 600 tempitem.flags &= ~ (item_flag3 | item_flag5);
7889 600 tempitem.misc1 = 0;
7890 600 tempitem.misc2 = 0;
7891 600 tempitem.misc3 = 0;
7892 600 tempitem.misc4 = 0;
7893 600 tempitem.misc5 = 0;
7894 600 tempitem.misc6 = 0;
7895 600 tempitem.misc7 = 0;
7896 600 tempitem.misc8 = 0;
7897 600 tempitem.misc9 = 0;
7898 600 tempitem.misc10 = 0;
7899 600 tempitem.wpn4 = 0;
7900 600 tempitem.wpn5 = 0;
7901 600 tempitem.wpn6 = 0;
7902 600 tempitem.wpn7 = 0;
7903 600 tempitem.wpn8 = 0;
7904 600 tempitem.wpn9 = 0;
7905 600 tempitem.wpn10 = 0;
7906 600 break;
7907 }
7908 case itype_whistle:
7909 {
7910 327 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7911 327 tempitem.misc3 = 0;
7912 327 tempitem.misc4 = 0;
7913 327 tempitem.misc5 = 0;
7914 327 tempitem.misc6 = 0;
7915 327 tempitem.misc7 = 0;
7916 327 tempitem.misc8 = 0;
7917 327 tempitem.misc9 = 0;
7918 327 tempitem.misc10 = 0;
7919 327 tempitem.wpn2 = 0;
7920 327 tempitem.wpn3 = 0;
7921 327 tempitem.wpn4 = 0;
7922 327 tempitem.wpn5 = 0;
7923 327 tempitem.wpn6 = 0;
7924 327 tempitem.wpn7 = 0;
7925 327 tempitem.wpn8 = 0;
7926 327 tempitem.wpn9 = 0;
7927 327 tempitem.wpn10 = 0;
7928 327 break;
7929 }
7930 case itype_bait:
7931 {
7932 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7933 282 tempitem.misc2 = 0;
7934 282 tempitem.misc3 = 0;
7935 282 tempitem.misc4 = 0;
7936 282 tempitem.misc5 = 0;
7937 282 tempitem.misc6 = 0;
7938 282 tempitem.misc7 = 0;
7939 282 tempitem.misc8 = 0;
7940 282 tempitem.misc9 = 0;
7941 282 tempitem.misc10 = 0;
7942 282 tempitem.wpn2 = 0;
7943 282 tempitem.wpn3 = 0;
7944 282 tempitem.wpn4 = 0;
7945 282 tempitem.wpn5 = 0;
7946 282 tempitem.wpn6 = 0;
7947 282 tempitem.wpn7 = 0;
7948 282 tempitem.wpn8 = 0;
7949 282 tempitem.wpn9 = 0;
7950 282 tempitem.wpn10 = 0;
7951 282 break;
7952 }
7953 case itype_letter:
7954 {
7955 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7956 558 tempitem.misc1 = 0;
7957 558 tempitem.misc2 = 0;
7958 558 tempitem.misc3 = 0;
7959 558 tempitem.misc4 = 0;
7960 558 tempitem.misc5 = 0;
7961 558 tempitem.misc6 = 0;
7962 558 tempitem.misc7 = 0;
7963 558 tempitem.misc8 = 0;
7964 558 tempitem.misc9 = 0;
7965 558 tempitem.misc10 = 0;
7966 558 tempitem.wpn = 0;
7967 558 tempitem.wpn2 = 0;
7968 558 tempitem.wpn3 = 0;
7969 558 tempitem.wpn4 = 0;
7970 558 tempitem.wpn5 = 0;
7971 558 tempitem.wpn6 = 0;
7972 558 tempitem.wpn7 = 0;
7973 558 tempitem.wpn8 = 0;
7974 558 tempitem.wpn9 = 0;
7975 558 tempitem.wpn10 = 0;
7976 558 break;
7977 }
7978 case itype_potion:
7979 {
7980 614 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7981 614 tempitem.misc3 = 0;
7982 614 tempitem.misc4 = 0;
7983 614 tempitem.misc5 = 0;
7984 614 tempitem.misc6 = 0;
7985 614 tempitem.misc7 = 0;
7986 614 tempitem.misc8 = 0;
7987 614 tempitem.misc9 = 0;
7988 614 tempitem.misc10 = 0;
7989 614 tempitem.wpn = 0;
7990 614 tempitem.wpn2 = 0;
7991 614 tempitem.wpn3 = 0;
7992 614 tempitem.wpn4 = 0;
7993 614 tempitem.wpn5 = 0;
7994 614 tempitem.wpn6 = 0;
7995 614 tempitem.wpn7 = 0;
7996 614 tempitem.wpn8 = 0;
7997 614 tempitem.wpn9 = 0;
7998 614 tempitem.wpn10 = 0;
7999 614 break;
8000 }
8001 case itype_wand:
8002 {
8003 297 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8004 297 tempitem.misc1 = 0;
8005 297 tempitem.misc2 = 0;
8006 297 tempitem.misc3 = 0;
8007 297 tempitem.misc4 = 0;
8008 297 tempitem.misc5 = 0;
8009 297 tempitem.misc6 = 0;
8010 297 tempitem.misc7 = 0;
8011 297 tempitem.misc8 = 0;
8012 297 tempitem.misc9 = 0;
8013 297 tempitem.misc10 = 0;
8014 297 tempitem.wpn4 = 0;
8015 297 tempitem.wpn5 = 0;
8016 297 tempitem.wpn6 = 0;
8017 297 tempitem.wpn7 = 0;
8018 297 tempitem.wpn8 = 0;
8019 297 tempitem.wpn9 = 0;
8020 297 tempitem.wpn10 = 0;
8021 297 break;
8022 }
8023 case itype_ring:
8024 {
8025 917 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8026 917 tempitem.misc2 = 0;
8027 917 tempitem.misc3 = 0;
8028 917 tempitem.misc4 = 0;
8029 917 tempitem.misc5 = 0;
8030 917 tempitem.misc6 = 0;
8031 917 tempitem.misc7 = 0;
8032 917 tempitem.misc8 = 0;
8033 917 tempitem.misc9 = 0;
8034 917 tempitem.misc10 = 0;
8035 917 tempitem.wpn = 0;
8036 917 tempitem.wpn2 = 0;
8037 917 tempitem.wpn3 = 0;
8038 917 tempitem.wpn4 = 0;
8039 917 tempitem.wpn5 = 0;
8040 917 tempitem.wpn6 = 0;
8041 917 tempitem.wpn7 = 0;
8042 917 tempitem.wpn8 = 0;
8043 917 tempitem.wpn9 = 0;
8044 917 tempitem.wpn10 = 0;
8045 917 break;
8046 }
8047 case itype_wallet:
8048 {
8049 892 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8050 892 tempitem.misc3 = 0;
8051 892 tempitem.misc4 = 0;
8052 892 tempitem.misc5 = 0;
8053 892 tempitem.misc6 = 0;
8054 892 tempitem.misc7 = 0;
8055 892 tempitem.misc8 = 0;
8056 892 tempitem.misc9 = 0;
8057 892 tempitem.misc10 = 0;
8058 892 tempitem.wpn = 0;
8059 892 tempitem.wpn2 = 0;
8060 892 tempitem.wpn3 = 0;
8061 892 tempitem.wpn4 = 0;
8062 892 tempitem.wpn5 = 0;
8063 892 tempitem.wpn6 = 0;
8064 892 tempitem.wpn7 = 0;
8065 892 tempitem.wpn8 = 0;
8066 892 tempitem.wpn9 = 0;
8067 892 tempitem.wpn10 = 0;
8068 892 break;
8069 }
8070 case itype_amulet:
8071 {
8072 557 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8073 557 tempitem.misc1 = 0;
8074 557 tempitem.misc2 = 0;
8075 557 tempitem.misc3 = 0;
8076 557 tempitem.misc4 = 0;
8077 557 tempitem.misc5 = 0;
8078 557 tempitem.misc6 = 0;
8079 557 tempitem.misc7 = 0;
8080 557 tempitem.misc8 = 0;
8081 557 tempitem.misc9 = 0;
8082 557 tempitem.misc10 = 0;
8083 557 tempitem.wpn = 0;
8084 557 tempitem.wpn2 = 0;
8085 557 tempitem.wpn3 = 0;
8086 557 tempitem.wpn4 = 0;
8087 557 tempitem.wpn5 = 0;
8088 557 tempitem.wpn6 = 0;
8089 557 tempitem.wpn7 = 0;
8090 557 tempitem.wpn8 = 0;
8091 557 tempitem.wpn9 = 0;
8092 557 tempitem.wpn10 = 0;
8093 557 break;
8094 }
8095 case itype_shield:
8096 {
8097 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8098 858 tempitem.misc3 = 0;
8099 858 tempitem.misc4 = 0;
8100 858 tempitem.misc5 = 0;
8101 858 tempitem.misc6 = 0;
8102 858 tempitem.misc7 = 0;
8103 858 tempitem.misc8 = 0;
8104 858 tempitem.misc9 = 0;
8105 858 tempitem.misc10 = 0;
8106 858 tempitem.wpn = 0;
8107 858 tempitem.wpn2 = 0;
8108 858 tempitem.wpn3 = 0;
8109 858 tempitem.wpn4 = 0;
8110 858 tempitem.wpn5 = 0;
8111 858 tempitem.wpn6 = 0;
8112 858 tempitem.wpn7 = 0;
8113 858 tempitem.wpn8 = 0;
8114 858 tempitem.wpn9 = 0;
8115 858 tempitem.wpn10 = 0;
8116 858 break;
8117 }
8118 case itype_bow:
8119 {
8120 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8121 558 tempitem.misc1 = 0;
8122 558 tempitem.misc2 = 0;
8123 558 tempitem.misc3 = 0;
8124 558 tempitem.misc4 = 0;
8125 558 tempitem.misc5 = 0;
8126 558 tempitem.misc6 = 0;
8127 558 tempitem.misc7 = 0;
8128 558 tempitem.misc8 = 0;
8129 558 tempitem.misc9 = 0;
8130 558 tempitem.misc10 = 0;
8131 558 tempitem.wpn = 0;
8132 558 tempitem.wpn2 = 0;
8133 558 tempitem.wpn3 = 0;
8134 558 tempitem.wpn4 = 0;
8135 558 tempitem.wpn5 = 0;
8136 558 tempitem.wpn6 = 0;
8137 558 tempitem.wpn7 = 0;
8138 558 tempitem.wpn8 = 0;
8139 558 tempitem.wpn9 = 0;
8140 558 tempitem.wpn10 = 0;
8141 558 break;
8142 }
8143 case itype_raft:
8144 {
8145 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8146 279 tempitem.misc1 = 0;
8147 279 tempitem.misc2 = 0;
8148 279 tempitem.misc3 = 0;
8149 279 tempitem.misc4 = 0;
8150 279 tempitem.misc5 = 0;
8151 279 tempitem.misc6 = 0;
8152 279 tempitem.misc7 = 0;
8153 279 tempitem.misc8 = 0;
8154 279 tempitem.misc9 = 0;
8155 279 tempitem.misc10 = 0;
8156 279 tempitem.wpn = 0;
8157 279 tempitem.wpn2 = 0;
8158 279 tempitem.wpn3 = 0;
8159 279 tempitem.wpn4 = 0;
8160 279 tempitem.wpn5 = 0;
8161 279 tempitem.wpn6 = 0;
8162 279 tempitem.wpn7 = 0;
8163 279 tempitem.wpn8 = 0;
8164 279 tempitem.wpn9 = 0;
8165 279 tempitem.wpn10 = 0;
8166 279 break;
8167 }
8168 case itype_ladder:
8169 {
8170 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8171 558 tempitem.misc1 = 0;
8172 558 tempitem.misc2 = 0;
8173 558 tempitem.misc3 = 0;
8174 558 tempitem.misc4 = 0;
8175 558 tempitem.misc5 = 0;
8176 558 tempitem.misc6 = 0;
8177 558 tempitem.misc7 = 0;
8178 558 tempitem.misc8 = 0;
8179 558 tempitem.misc9 = 0;
8180 558 tempitem.misc10 = 0;
8181 558 tempitem.wpn = 0;
8182 558 tempitem.wpn2 = 0;
8183 558 tempitem.wpn3 = 0;
8184 558 tempitem.wpn4 = 0;
8185 558 tempitem.wpn5 = 0;
8186 558 tempitem.wpn6 = 0;
8187 558 tempitem.wpn7 = 0;
8188 558 tempitem.wpn8 = 0;
8189 558 tempitem.wpn9 = 0;
8190 558 tempitem.wpn10 = 0;
8191 558 break;
8192 }
8193 case itype_book:
8194 {
8195 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8196 295 tempitem.misc1 = 0;
8197 295 tempitem.misc2 = 0;
8198 295 tempitem.misc3 = 0;
8199 295 tempitem.misc4 = 0;
8200 295 tempitem.misc5 = 0;
8201 295 tempitem.misc6 = 0;
8202 295 tempitem.misc7 = 0;
8203 295 tempitem.misc8 = 0;
8204 295 tempitem.misc9 = 0;
8205 295 tempitem.misc10 = 0;
8206 295 tempitem.wpn3 = 0;
8207 295 tempitem.wpn4 = 0;
8208 295 tempitem.wpn5 = 0;
8209 295 tempitem.wpn6 = 0;
8210 295 tempitem.wpn7 = 0;
8211 295 tempitem.wpn8 = 0;
8212 295 tempitem.wpn9 = 0;
8213 295 tempitem.wpn10 = 0;
8214 295 break;
8215 }
8216 case itype_magickey:
8217 {
8218 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8219 279 tempitem.misc1 = 0;
8220 279 tempitem.misc2 = 0;
8221 279 tempitem.misc3 = 0;
8222 279 tempitem.misc4 = 0;
8223 279 tempitem.misc5 = 0;
8224 279 tempitem.misc6 = 0;
8225 279 tempitem.misc7 = 0;
8226 279 tempitem.misc8 = 0;
8227 279 tempitem.misc9 = 0;
8228 279 tempitem.misc10 = 0;
8229 279 tempitem.wpn = 0;
8230 279 tempitem.wpn2 = 0;
8231 279 tempitem.wpn3 = 0;
8232 279 tempitem.wpn4 = 0;
8233 279 tempitem.wpn5 = 0;
8234 279 tempitem.wpn6 = 0;
8235 279 tempitem.wpn7 = 0;
8236 279 tempitem.wpn8 = 0;
8237 279 tempitem.wpn9 = 0;
8238 279 tempitem.wpn10 = 0;
8239 279 break;
8240 }
8241 case itype_bracelet:
8242 {
8243 846 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8244 846 tempitem.misc1 = 0;
8245 846 tempitem.misc2 = 0;
8246 846 tempitem.misc3 = 0;
8247 846 tempitem.misc4 = 0;
8248 846 tempitem.misc5 = 0;
8249 846 tempitem.misc6 = 0;
8250 846 tempitem.misc7 = 0;
8251 846 tempitem.misc8 = 0;
8252 846 tempitem.misc9 = 0;
8253 846 tempitem.misc10 = 0;
8254 846 tempitem.wpn = 0;
8255 846 tempitem.wpn2 = 0;
8256 846 tempitem.wpn3 = 0;
8257 846 tempitem.wpn4 = 0;
8258 846 tempitem.wpn5 = 0;
8259 846 tempitem.wpn6 = 0;
8260 846 tempitem.wpn7 = 0;
8261 846 tempitem.wpn8 = 0;
8262 846 tempitem.wpn9 = 0;
8263 846 tempitem.wpn10 = 0;
8264 846 break;
8265 }
8266 case itype_flippers:
8267 {
8268 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8269 282 tempitem.misc1 = 0;
8270 282 tempitem.misc2 = 0;
8271 282 tempitem.misc3 = 0;
8272 282 tempitem.misc4 = 0;
8273 282 tempitem.misc5 = 0;
8274 282 tempitem.misc6 = 0;
8275 282 tempitem.misc7 = 0;
8276 282 tempitem.misc8 = 0;
8277 282 tempitem.misc9 = 0;
8278 282 tempitem.misc10 = 0;
8279 282 tempitem.wpn = 0;
8280 282 tempitem.wpn2 = 0;
8281 282 tempitem.wpn3 = 0;
8282 282 tempitem.wpn4 = 0;
8283 282 tempitem.wpn5 = 0;
8284 282 tempitem.wpn6 = 0;
8285 282 tempitem.wpn7 = 0;
8286 282 tempitem.wpn8 = 0;
8287 282 tempitem.wpn9 = 0;
8288 282 tempitem.wpn10 = 0;
8289 282 break;
8290 }
8291 case itype_boots:
8292 {
8293 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8294 285 tempitem.misc1 = 0;
8295 285 tempitem.misc2 = 0;
8296 285 tempitem.misc3 = 0;
8297 285 tempitem.misc4 = 0;
8298 285 tempitem.misc5 = 0;
8299 285 tempitem.misc6 = 0;
8300 285 tempitem.misc7 = 0;
8301 285 tempitem.misc8 = 0;
8302 285 tempitem.misc9 = 0;
8303 285 tempitem.misc10 = 0;
8304 285 tempitem.wpn = 0;
8305 285 tempitem.wpn2 = 0;
8306 285 tempitem.wpn3 = 0;
8307 285 tempitem.wpn4 = 0;
8308 285 tempitem.wpn5 = 0;
8309 285 tempitem.wpn6 = 0;
8310 285 tempitem.wpn7 = 0;
8311 285 tempitem.wpn8 = 0;
8312 285 tempitem.wpn9 = 0;
8313 285 tempitem.wpn10 = 0;
8314 285 break;
8315 }
8316 case itype_hookshot:
8317 {
8318 560 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8319 560 tempitem.misc5 = 0;
8320 560 tempitem.misc6 = 0;
8321 560 tempitem.misc7 = 0;
8322 560 tempitem.misc8 = 0;
8323 560 tempitem.misc9 = 0;
8324 560 tempitem.misc10 = 0;
8325 560 tempitem.wpn5 = 0;
8326 560 tempitem.wpn6 = 0;
8327 560 tempitem.wpn7 = 0;
8328 560 tempitem.wpn8 = 0;
8329 560 tempitem.wpn9 = 0;
8330 560 tempitem.wpn10 = 0;
8331 560 break;
8332 }
8333 case itype_lens:
8334 {
8335 255 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8336 255 tempitem.misc2 = 0;
8337 255 tempitem.misc3 = 0;
8338 255 tempitem.misc4 = 0;
8339 255 tempitem.misc5 = 0;
8340 255 tempitem.misc6 = 0;
8341 255 tempitem.misc7 = 0;
8342 255 tempitem.misc8 = 0;
8343 255 tempitem.misc9 = 0;
8344 255 tempitem.misc10 = 0;
8345 255 tempitem.wpn = 0;
8346 255 tempitem.wpn2 = 0;
8347 255 tempitem.wpn3 = 0;
8348 255 tempitem.wpn4 = 0;
8349 255 tempitem.wpn5 = 0;
8350 255 tempitem.wpn6 = 0;
8351 255 tempitem.wpn7 = 0;
8352 255 tempitem.wpn8 = 0;
8353 255 tempitem.wpn9 = 0;
8354 255 tempitem.wpn10 = 0;
8355 255 break;
8356 }
8357 case itype_hammer:
8358 {
8359 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8360 282 tempitem.misc1 = 0;
8361 282 tempitem.misc2 = 0;
8362 282 tempitem.misc3 = 0;
8363 282 tempitem.misc4 = 0;
8364 282 tempitem.misc5 = 0;
8365 282 tempitem.misc6 = 0;
8366 282 tempitem.misc7 = 0;
8367 282 tempitem.misc8 = 0;
8368 282 tempitem.misc9 = 0;
8369 282 tempitem.misc10 = 0;
8370 282 tempitem.wpn3 = 0;
8371 282 tempitem.wpn4 = 0;
8372 282 tempitem.wpn5 = 0;
8373 282 tempitem.wpn6 = 0;
8374 282 tempitem.wpn7 = 0;
8375 282 tempitem.wpn8 = 0;
8376 282 tempitem.wpn9 = 0;
8377 282 tempitem.wpn10 = 0;
8378 282 break;
8379 }
8380 case itype_divinefire:
8381 {
8382 279 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8383 279 tempitem.misc3 = 0;
8384 279 tempitem.misc4 = 0;
8385 279 tempitem.misc5 = 0;
8386 279 tempitem.misc6 = 0;
8387 279 tempitem.misc7 = 0;
8388 279 tempitem.misc8 = 0;
8389 279 tempitem.misc9 = 0;
8390 279 tempitem.misc10 = 0;
8391 279 tempitem.wpn6 = 0;
8392 279 tempitem.wpn7 = 0;
8393 279 tempitem.wpn8 = 0;
8394 279 tempitem.wpn9 = 0;
8395 279 tempitem.wpn10 = 0;
8396 279 break;
8397 }
8398 case itype_divineescape:
8399 {
8400 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8401 279 tempitem.misc2 = 0;
8402 279 tempitem.misc3 = 0;
8403 279 tempitem.misc4 = 0;
8404 279 tempitem.misc5 = 0;
8405 279 tempitem.misc6 = 0;
8406 279 tempitem.misc7 = 0;
8407 279 tempitem.misc8 = 0;
8408 279 tempitem.misc9 = 0;
8409 279 tempitem.misc10 = 0;
8410 279 tempitem.wpn = 0;
8411 279 tempitem.wpn2 = 0;
8412 279 tempitem.wpn3 = 0;
8413 279 tempitem.wpn4 = 0;
8414 279 tempitem.wpn5 = 0;
8415 279 tempitem.wpn6 = 0;
8416 279 tempitem.wpn7 = 0;
8417 279 tempitem.wpn8 = 0;
8418 279 tempitem.wpn9 = 0;
8419 279 tempitem.wpn10 = 0;
8420 279 break;
8421 }
8422 case itype_divineprotection:
8423 {
8424 279 tempitem.flags &= ~ (item_flag5);
8425 279 tempitem.misc2 = 0;
8426 279 tempitem.misc3 = 0;
8427 279 tempitem.misc4 = 0;
8428 279 tempitem.misc5 = 0;
8429 279 tempitem.misc6 = 0;
8430 279 tempitem.misc7 = 0;
8431 279 tempitem.misc8 = 0;
8432 279 tempitem.misc9 = 0;
8433 279 tempitem.misc10 = 0;
8434 279 break;
8435 }
8436 case itype_bomb:
8437 {
8438 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8439 295 tempitem.misc4 = 0;
8440 295 tempitem.misc5 = 0;
8441 295 tempitem.misc6 = 0;
8442 295 tempitem.misc7 = 0;
8443 295 tempitem.misc8 = 0;
8444 295 tempitem.misc9 = 0;
8445 295 tempitem.misc10 = 0;
8446 295 tempitem.wpn3 = 0;
8447 295 tempitem.wpn4 = 0;
8448 295 tempitem.wpn5 = 0;
8449 295 tempitem.wpn6 = 0;
8450 295 tempitem.wpn7 = 0;
8451 295 tempitem.wpn8 = 0;
8452 295 tempitem.wpn9 = 0;
8453 295 tempitem.wpn10 = 0;
8454 295 break;
8455 }
8456 case itype_sbomb:
8457 {
8458 281 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8459 281 tempitem.misc4 = 0;
8460 281 tempitem.misc5 = 0;
8461 281 tempitem.misc6 = 0;
8462 281 tempitem.misc7 = 0;
8463 281 tempitem.misc8 = 0;
8464 281 tempitem.misc9 = 0;
8465 281 tempitem.misc10 = 0;
8466 281 tempitem.wpn3 = 0;
8467 281 tempitem.wpn4 = 0;
8468 281 tempitem.wpn5 = 0;
8469 281 tempitem.wpn6 = 0;
8470 281 tempitem.wpn7 = 0;
8471 281 tempitem.wpn8 = 0;
8472 281 tempitem.wpn9 = 0;
8473 281 tempitem.wpn10 = 0;
8474 281 break;
8475 }
8476 case itype_clock:
8477 {
8478 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8479 282 tempitem.misc2 = 0;
8480 282 tempitem.misc3 = 0;
8481 282 tempitem.misc4 = 0;
8482 282 tempitem.misc5 = 0;
8483 282 tempitem.misc6 = 0;
8484 282 tempitem.misc7 = 0;
8485 282 tempitem.misc8 = 0;
8486 282 tempitem.misc9 = 0;
8487 282 tempitem.misc10 = 0;
8488 282 tempitem.wpn = 0;
8489 282 tempitem.wpn2 = 0;
8490 282 tempitem.wpn3 = 0;
8491 282 tempitem.wpn4 = 0;
8492 282 tempitem.wpn5 = 0;
8493 282 tempitem.wpn6 = 0;
8494 282 tempitem.wpn7 = 0;
8495 282 tempitem.wpn8 = 0;
8496 282 tempitem.wpn9 = 0;
8497 282 tempitem.wpn10 = 0;
8498 282 break;
8499 }
8500 case itype_key:
8501 {
8502 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8503 279 tempitem.misc1 = 0;
8504 279 tempitem.misc2 = 0;
8505 279 tempitem.misc3 = 0;
8506 279 tempitem.misc4 = 0;
8507 279 tempitem.misc5 = 0;
8508 279 tempitem.misc6 = 0;
8509 279 tempitem.misc7 = 0;
8510 279 tempitem.misc8 = 0;
8511 279 tempitem.misc9 = 0;
8512 279 tempitem.misc10 = 0;
8513 279 tempitem.wpn = 0;
8514 279 tempitem.wpn2 = 0;
8515 279 tempitem.wpn3 = 0;
8516 279 tempitem.wpn4 = 0;
8517 279 tempitem.wpn5 = 0;
8518 279 tempitem.wpn6 = 0;
8519 279 tempitem.wpn7 = 0;
8520 279 tempitem.wpn8 = 0;
8521 279 tempitem.wpn9 = 0;
8522 279 tempitem.wpn10 = 0;
8523 279 break;
8524 }
8525 case itype_magiccontainer:
8526 {
8527 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8528 284 tempitem.misc1 = 0;
8529 284 tempitem.misc2 = 0;
8530 284 tempitem.misc3 = 0;
8531 284 tempitem.misc4 = 0;
8532 284 tempitem.misc5 = 0;
8533 284 tempitem.misc6 = 0;
8534 284 tempitem.misc7 = 0;
8535 284 tempitem.misc8 = 0;
8536 284 tempitem.misc9 = 0;
8537 284 tempitem.misc10 = 0;
8538 284 tempitem.wpn = 0;
8539 284 tempitem.wpn2 = 0;
8540 284 tempitem.wpn3 = 0;
8541 284 tempitem.wpn4 = 0;
8542 284 tempitem.wpn5 = 0;
8543 284 tempitem.wpn6 = 0;
8544 284 tempitem.wpn7 = 0;
8545 284 tempitem.wpn8 = 0;
8546 284 tempitem.wpn9 = 0;
8547 284 tempitem.wpn10 = 0;
8548 284 break;
8549 }
8550 case itype_triforcepiece:
8551 {
8552 558 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8553 558 tempitem.misc3 = 0;
8554 558 tempitem.misc4 = 0;
8555 558 tempitem.misc5 = 0;
8556 558 tempitem.misc6 = 0;
8557 558 tempitem.misc7 = 0;
8558 558 tempitem.misc8 = 0;
8559 558 tempitem.misc9 = 0;
8560 558 tempitem.misc10 = 0;
8561 558 tempitem.wpn = 0;
8562 558 tempitem.wpn2 = 0;
8563 558 tempitem.wpn3 = 0;
8564 558 tempitem.wpn4 = 0;
8565 558 tempitem.wpn5 = 0;
8566 558 tempitem.wpn6 = 0;
8567 558 tempitem.wpn7 = 0;
8568 558 tempitem.wpn8 = 0;
8569 558 tempitem.wpn9 = 0;
8570 558 tempitem.wpn10 = 0;
8571 558 break;
8572 }
8573 case itype_map: case itype_compass: case itype_bosskey:
8574 {
8575 842 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8576 842 tempitem.misc1 = 0;
8577 842 tempitem.misc2 = 0;
8578 842 tempitem.misc3 = 0;
8579 842 tempitem.misc4 = 0;
8580 842 tempitem.misc5 = 0;
8581 842 tempitem.misc6 = 0;
8582 842 tempitem.misc7 = 0;
8583 842 tempitem.misc8 = 0;
8584 842 tempitem.misc9 = 0;
8585 842 tempitem.misc10 = 0;
8586 842 tempitem.wpn = 0;
8587 842 tempitem.wpn2 = 0;
8588 842 tempitem.wpn3 = 0;
8589 842 tempitem.wpn4 = 0;
8590 842 tempitem.wpn5 = 0;
8591 842 tempitem.wpn6 = 0;
8592 842 tempitem.wpn7 = 0;
8593 842 tempitem.wpn8 = 0;
8594 842 tempitem.wpn9 = 0;
8595 842 tempitem.wpn10 = 0;
8596 842 break;
8597 }
8598 case itype_quiver:
8599 {
8600 1116 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8601 1116 tempitem.misc3 = 0;
8602 1116 tempitem.misc4 = 0;
8603 1116 tempitem.misc5 = 0;
8604 1116 tempitem.misc6 = 0;
8605 1116 tempitem.misc7 = 0;
8606 1116 tempitem.misc8 = 0;
8607 1116 tempitem.misc9 = 0;
8608 1116 tempitem.misc10 = 0;
8609 1116 tempitem.wpn = 0;
8610 1116 tempitem.wpn2 = 0;
8611 1116 tempitem.wpn3 = 0;
8612 1116 tempitem.wpn4 = 0;
8613 1116 tempitem.wpn5 = 0;
8614 1116 tempitem.wpn6 = 0;
8615 1116 tempitem.wpn7 = 0;
8616 1116 tempitem.wpn8 = 0;
8617 1116 tempitem.wpn9 = 0;
8618 1116 tempitem.wpn10 = 0;
8619 1116 break;
8620 }
8621 case itype_lkey:
8622 {
8623 780 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8624 780 tempitem.misc1 = 0;
8625 780 tempitem.misc2 = 0;
8626 780 tempitem.misc3 = 0;
8627 780 tempitem.misc4 = 0;
8628 780 tempitem.misc5 = 0;
8629 780 tempitem.misc6 = 0;
8630 780 tempitem.misc7 = 0;
8631 780 tempitem.misc8 = 0;
8632 780 tempitem.misc9 = 0;
8633 780 tempitem.misc10 = 0;
8634 780 tempitem.wpn = 0;
8635 780 tempitem.wpn2 = 0;
8636 780 tempitem.wpn3 = 0;
8637 780 tempitem.wpn4 = 0;
8638 780 tempitem.wpn5 = 0;
8639 780 tempitem.wpn6 = 0;
8640 780 tempitem.wpn7 = 0;
8641 780 tempitem.wpn8 = 0;
8642 780 tempitem.wpn9 = 0;
8643 780 tempitem.wpn10 = 0;
8644 780 break;
8645 }
8646 case itype_cbyrna:
8647 {
8648 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8649 279 tempitem.misc4 = 0;
8650 279 tempitem.misc5 = 0;
8651 279 tempitem.misc6 = 0;
8652 279 tempitem.misc7 = 0;
8653 279 tempitem.misc8 = 0;
8654 279 tempitem.misc9 = 0;
8655 279 tempitem.misc10 = 0;
8656 279 tempitem.wpn6 = 0;
8657 279 tempitem.wpn7 = 0;
8658 279 tempitem.wpn8 = 0;
8659 279 tempitem.wpn9 = 0;
8660 279 tempitem.wpn10 = 0;
8661 279 break;
8662 }
8663 case itype_rupee: case itype_arrowammo:
8664 {
8665 3261 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8666 3261 tempitem.misc1 = 0;
8667 3261 tempitem.misc2 = 0;
8668 3261 tempitem.misc3 = 0;
8669 3261 tempitem.misc4 = 0;
8670 3261 tempitem.misc5 = 0;
8671 3261 tempitem.misc6 = 0;
8672 3261 tempitem.misc7 = 0;
8673 3261 tempitem.misc8 = 0;
8674 3261 tempitem.misc9 = 0;
8675 3261 tempitem.misc10 = 0;
8676 3261 tempitem.wpn = 0;
8677 3261 tempitem.wpn2 = 0;
8678 3261 tempitem.wpn3 = 0;
8679 3261 tempitem.wpn4 = 0;
8680 3261 tempitem.wpn5 = 0;
8681 3261 tempitem.wpn6 = 0;
8682 3261 tempitem.wpn7 = 0;
8683 3261 tempitem.wpn8 = 0;
8684 3261 tempitem.wpn9 = 0;
8685 3261 tempitem.wpn10 = 0;
8686 3261 break;
8687 }
8688 case itype_fairy:
8689 {
8690 545 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8691 545 tempitem.misc4 = 0;
8692 545 tempitem.misc5 = 0;
8693 545 tempitem.misc6 = 0;
8694 545 tempitem.misc7 = 0;
8695 545 tempitem.misc8 = 0;
8696 545 tempitem.misc9 = 0;
8697 545 tempitem.misc10 = 0;
8698 545 tempitem.wpn = 0;
8699 545 tempitem.wpn2 = 0;
8700 545 tempitem.wpn3 = 0;
8701 545 tempitem.wpn4 = 0;
8702 545 tempitem.wpn5 = 0;
8703 545 tempitem.wpn6 = 0;
8704 545 tempitem.wpn7 = 0;
8705 545 tempitem.wpn8 = 0;
8706 545 tempitem.wpn9 = 0;
8707 545 tempitem.wpn10 = 0;
8708 545 break;
8709 }
8710 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8711 {
8712 2872 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8713 2872 tempitem.misc1 = 0;
8714 2872 tempitem.misc2 = 0;
8715 2872 tempitem.misc3 = 0;
8716 2872 tempitem.misc4 = 0;
8717 2872 tempitem.misc5 = 0;
8718 2872 tempitem.misc6 = 0;
8719 2872 tempitem.misc7 = 0;
8720 2872 tempitem.misc8 = 0;
8721 2872 tempitem.misc9 = 0;
8722 2872 tempitem.misc10 = 0;
8723 2872 tempitem.wpn = 0;
8724 2872 tempitem.wpn2 = 0;
8725 2872 tempitem.wpn3 = 0;
8726 2872 tempitem.wpn4 = 0;
8727 2872 tempitem.wpn5 = 0;
8728 2872 tempitem.wpn6 = 0;
8729 2872 tempitem.wpn7 = 0;
8730 2872 tempitem.wpn8 = 0;
8731 2872 tempitem.wpn9 = 0;
8732 2872 tempitem.wpn10 = 0;
8733 2872 break;
8734 }
8735 case itype_bombbag:
8736 {
8737 1116 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8738 1116 tempitem.misc3 = 0;
8739 1116 tempitem.misc4 = 0;
8740 1116 tempitem.misc5 = 0;
8741 1116 tempitem.misc6 = 0;
8742 1116 tempitem.misc7 = 0;
8743 1116 tempitem.misc8 = 0;
8744 1116 tempitem.misc9 = 0;
8745 1116 tempitem.misc10 = 0;
8746 1116 tempitem.wpn = 0;
8747 1116 tempitem.wpn2 = 0;
8748 1116 tempitem.wpn3 = 0;
8749 1116 tempitem.wpn4 = 0;
8750 1116 tempitem.wpn5 = 0;
8751 1116 tempitem.wpn6 = 0;
8752 1116 tempitem.wpn7 = 0;
8753 1116 tempitem.wpn8 = 0;
8754 1116 tempitem.wpn9 = 0;
8755 1116 tempitem.wpn10 = 0;
8756 1116 break;
8757 }
8758 case itype_rocs:
8759 {
8760 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8761 279 tempitem.misc1 = 0;
8762 279 tempitem.misc2 = 0;
8763 279 tempitem.misc3 = 0;
8764 279 tempitem.misc4 = 0;
8765 279 tempitem.misc5 = 0;
8766 279 tempitem.misc6 = 0;
8767 279 tempitem.misc7 = 0;
8768 279 tempitem.misc8 = 0;
8769 279 tempitem.misc9 = 0;
8770 279 tempitem.misc10 = 0;
8771 279 tempitem.wpn = 0;
8772 279 tempitem.wpn2 = 0;
8773 279 tempitem.wpn3 = 0;
8774 279 tempitem.wpn4 = 0;
8775 279 tempitem.wpn5 = 0;
8776 279 tempitem.wpn6 = 0;
8777 279 tempitem.wpn7 = 0;
8778 279 tempitem.wpn8 = 0;
8779 279 tempitem.wpn9 = 0;
8780 279 tempitem.wpn10 = 0;
8781 279 break;
8782 }
8783 case itype_hoverboots:
8784 {
8785 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8786 279 tempitem.misc2 = 0;
8787 279 tempitem.misc3 = 0;
8788 279 tempitem.misc4 = 0;
8789 279 tempitem.misc5 = 0;
8790 279 tempitem.misc6 = 0;
8791 279 tempitem.misc7 = 0;
8792 279 tempitem.misc8 = 0;
8793 279 tempitem.misc9 = 0;
8794 279 tempitem.misc10 = 0;
8795 279 tempitem.wpn2 = 0;
8796 279 tempitem.wpn3 = 0;
8797 279 tempitem.wpn4 = 0;
8798 279 tempitem.wpn5 = 0;
8799 279 tempitem.wpn6 = 0;
8800 279 tempitem.wpn7 = 0;
8801 279 tempitem.wpn8 = 0;
8802 279 tempitem.wpn9 = 0;
8803 279 tempitem.wpn10 = 0;
8804 279 break;
8805 }
8806 case itype_spinscroll:
8807 {
8808 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8809 279 tempitem.misc2 = 0;
8810 279 tempitem.misc3 = 0;
8811 279 tempitem.misc4 = 0;
8812 279 tempitem.misc5 = 0;
8813 279 tempitem.misc6 = 0;
8814 279 tempitem.misc7 = 0;
8815 279 tempitem.misc8 = 0;
8816 279 tempitem.misc9 = 0;
8817 279 tempitem.misc10 = 0;
8818 279 tempitem.wpn = 0;
8819 279 tempitem.wpn2 = 0;
8820 279 tempitem.wpn3 = 0;
8821 279 tempitem.wpn4 = 0;
8822 279 tempitem.wpn5 = 0;
8823 279 tempitem.wpn6 = 0;
8824 279 tempitem.wpn7 = 0;
8825 279 tempitem.wpn8 = 0;
8826 279 tempitem.wpn9 = 0;
8827 279 tempitem.wpn10 = 0;
8828 279 break;
8829 }
8830 case itype_crossscroll:
8831 {
8832 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8833 279 tempitem.misc1 = 0;
8834 279 tempitem.misc2 = 0;
8835 279 tempitem.misc3 = 0;
8836 279 tempitem.misc4 = 0;
8837 279 tempitem.misc5 = 0;
8838 279 tempitem.misc6 = 0;
8839 279 tempitem.misc7 = 0;
8840 279 tempitem.misc8 = 0;
8841 279 tempitem.misc9 = 0;
8842 279 tempitem.misc10 = 0;
8843 279 tempitem.wpn = 0;
8844 279 tempitem.wpn2 = 0;
8845 279 tempitem.wpn3 = 0;
8846 279 tempitem.wpn4 = 0;
8847 279 tempitem.wpn5 = 0;
8848 279 tempitem.wpn6 = 0;
8849 279 tempitem.wpn7 = 0;
8850 279 tempitem.wpn8 = 0;
8851 279 tempitem.wpn9 = 0;
8852 279 tempitem.wpn10 = 0;
8853 279 break;
8854 }
8855 case itype_quakescroll:
8856 {
8857 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8858 279 tempitem.misc3 = 0;
8859 279 tempitem.misc4 = 0;
8860 279 tempitem.misc5 = 0;
8861 279 tempitem.misc6 = 0;
8862 279 tempitem.misc7 = 0;
8863 279 tempitem.misc8 = 0;
8864 279 tempitem.misc9 = 0;
8865 279 tempitem.misc10 = 0;
8866 279 tempitem.wpn = 0;
8867 279 tempitem.wpn2 = 0;
8868 279 tempitem.wpn3 = 0;
8869 279 tempitem.wpn4 = 0;
8870 279 tempitem.wpn5 = 0;
8871 279 tempitem.wpn6 = 0;
8872 279 tempitem.wpn7 = 0;
8873 279 tempitem.wpn8 = 0;
8874 279 tempitem.wpn9 = 0;
8875 279 tempitem.wpn10 = 0;
8876 279 break;
8877 }
8878 case itype_whispring:
8879 {
8880 561 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8881 561 tempitem.misc2 = 0;
8882 561 tempitem.misc3 = 0;
8883 561 tempitem.misc4 = 0;
8884 561 tempitem.misc5 = 0;
8885 561 tempitem.misc6 = 0;
8886 561 tempitem.misc7 = 0;
8887 561 tempitem.misc8 = 0;
8888 561 tempitem.misc9 = 0;
8889 561 tempitem.misc10 = 0;
8890 561 tempitem.wpn = 0;
8891 561 tempitem.wpn2 = 0;
8892 561 tempitem.wpn3 = 0;
8893 561 tempitem.wpn4 = 0;
8894 561 tempitem.wpn5 = 0;
8895 561 tempitem.wpn6 = 0;
8896 561 tempitem.wpn7 = 0;
8897 561 tempitem.wpn8 = 0;
8898 561 tempitem.wpn9 = 0;
8899 561 tempitem.wpn10 = 0;
8900 561 break;
8901 }
8902 case itype_chargering:
8903 {
8904 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8905 558 tempitem.misc3 = 0;
8906 558 tempitem.misc4 = 0;
8907 558 tempitem.misc5 = 0;
8908 558 tempitem.misc6 = 0;
8909 558 tempitem.misc7 = 0;
8910 558 tempitem.misc8 = 0;
8911 558 tempitem.misc9 = 0;
8912 558 tempitem.misc10 = 0;
8913 558 tempitem.wpn = 0;
8914 558 tempitem.wpn2 = 0;
8915 558 tempitem.wpn3 = 0;
8916 558 tempitem.wpn4 = 0;
8917 558 tempitem.wpn5 = 0;
8918 558 tempitem.wpn6 = 0;
8919 558 tempitem.wpn7 = 0;
8920 558 tempitem.wpn8 = 0;
8921 558 tempitem.wpn9 = 0;
8922 558 tempitem.wpn10 = 0;
8923 558 break;
8924 }
8925 case itype_perilscroll:
8926 {
8927 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8928 279 tempitem.misc2 = 0;
8929 279 tempitem.misc3 = 0;
8930 279 tempitem.misc4 = 0;
8931 279 tempitem.misc5 = 0;
8932 279 tempitem.misc6 = 0;
8933 279 tempitem.misc7 = 0;
8934 279 tempitem.misc8 = 0;
8935 279 tempitem.misc9 = 0;
8936 279 tempitem.misc10 = 0;
8937 279 tempitem.wpn = 0;
8938 279 tempitem.wpn2 = 0;
8939 279 tempitem.wpn3 = 0;
8940 279 tempitem.wpn4 = 0;
8941 279 tempitem.wpn5 = 0;
8942 279 tempitem.wpn6 = 0;
8943 279 tempitem.wpn7 = 0;
8944 279 tempitem.wpn8 = 0;
8945 279 tempitem.wpn9 = 0;
8946 279 tempitem.wpn10 = 0;
8947 279 break;
8948 }
8949 case itype_wealthmedal:
8950 {
8951 840 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8952 840 tempitem.misc2 = 0;
8953 840 tempitem.misc3 = 0;
8954 840 tempitem.misc4 = 0;
8955 840 tempitem.misc5 = 0;
8956 840 tempitem.misc6 = 0;
8957 840 tempitem.misc7 = 0;
8958 840 tempitem.misc8 = 0;
8959 840 tempitem.misc9 = 0;
8960 840 tempitem.misc10 = 0;
8961 840 tempitem.wpn = 0;
8962 840 tempitem.wpn2 = 0;
8963 840 tempitem.wpn3 = 0;
8964 840 tempitem.wpn4 = 0;
8965 840 tempitem.wpn5 = 0;
8966 840 tempitem.wpn6 = 0;
8967 840 tempitem.wpn7 = 0;
8968 840 tempitem.wpn8 = 0;
8969 840 tempitem.wpn9 = 0;
8970 840 tempitem.wpn10 = 0;
8971 840 break;
8972 }
8973 case itype_heartring:
8974 {
8975 843 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8976 843 tempitem.misc3 = 0;
8977 843 tempitem.misc4 = 0;
8978 843 tempitem.misc5 = 0;
8979 843 tempitem.misc6 = 0;
8980 843 tempitem.misc7 = 0;
8981 843 tempitem.misc8 = 0;
8982 843 tempitem.misc9 = 0;
8983 843 tempitem.misc10 = 0;
8984 843 tempitem.wpn = 0;
8985 843 tempitem.wpn2 = 0;
8986 843 tempitem.wpn3 = 0;
8987 843 tempitem.wpn4 = 0;
8988 843 tempitem.wpn5 = 0;
8989 843 tempitem.wpn6 = 0;
8990 843 tempitem.wpn7 = 0;
8991 843 tempitem.wpn8 = 0;
8992 843 tempitem.wpn9 = 0;
8993 843 tempitem.wpn10 = 0;
8994 843 break;
8995 }
8996 case itype_magicring:
8997 {
8998 1128 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8999 1128 tempitem.misc3 = 0;
9000 1128 tempitem.misc4 = 0;
9001 1128 tempitem.misc5 = 0;
9002 1128 tempitem.misc6 = 0;
9003 1128 tempitem.misc7 = 0;
9004 1128 tempitem.misc8 = 0;
9005 1128 tempitem.misc9 = 0;
9006 1128 tempitem.misc10 = 0;
9007 1128 tempitem.wpn = 0;
9008 1128 tempitem.wpn2 = 0;
9009 1128 tempitem.wpn3 = 0;
9010 1128 tempitem.wpn4 = 0;
9011 1128 tempitem.wpn5 = 0;
9012 1128 tempitem.wpn6 = 0;
9013 1128 tempitem.wpn7 = 0;
9014 1128 tempitem.wpn8 = 0;
9015 1128 tempitem.wpn9 = 0;
9016 1128 tempitem.wpn10 = 0;
9017 1128 break;
9018 }
9019 case itype_spinscroll2:
9020 {
9021 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9022 279 tempitem.misc2 = 0;
9023 279 tempitem.misc3 = 0;
9024 279 tempitem.misc4 = 0;
9025 279 tempitem.misc5 = 0;
9026 279 tempitem.misc6 = 0;
9027 279 tempitem.misc7 = 0;
9028 279 tempitem.misc8 = 0;
9029 279 tempitem.misc9 = 0;
9030 279 tempitem.misc10 = 0;
9031 279 tempitem.wpn = 0;
9032 279 tempitem.wpn2 = 0;
9033 279 tempitem.wpn3 = 0;
9034 279 tempitem.wpn4 = 0;
9035 279 tempitem.wpn5 = 0;
9036 279 tempitem.wpn6 = 0;
9037 279 tempitem.wpn7 = 0;
9038 279 tempitem.wpn8 = 0;
9039 279 tempitem.wpn9 = 0;
9040 279 tempitem.wpn10 = 0;
9041 279 break;
9042 }
9043 case itype_quakescroll2:
9044 {
9045 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9046 279 tempitem.misc3 = 0;
9047 279 tempitem.misc4 = 0;
9048 279 tempitem.misc5 = 0;
9049 279 tempitem.misc6 = 0;
9050 279 tempitem.misc7 = 0;
9051 279 tempitem.misc8 = 0;
9052 279 tempitem.misc9 = 0;
9053 279 tempitem.misc10 = 0;
9054 279 tempitem.wpn = 0;
9055 279 tempitem.wpn2 = 0;
9056 279 tempitem.wpn3 = 0;
9057 279 tempitem.wpn4 = 0;
9058 279 tempitem.wpn5 = 0;
9059 279 tempitem.wpn6 = 0;
9060 279 tempitem.wpn7 = 0;
9061 279 tempitem.wpn8 = 0;
9062 279 tempitem.wpn9 = 0;
9063 279 tempitem.wpn10 = 0;
9064 279 break;
9065 }
9066 case itype_agony:
9067 {
9068 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9069 279 tempitem.misc2 = 0;
9070 279 tempitem.misc3 = 0;
9071 279 tempitem.misc4 = 0;
9072 279 tempitem.misc5 = 0;
9073 279 tempitem.misc6 = 0;
9074 279 tempitem.misc7 = 0;
9075 279 tempitem.misc8 = 0;
9076 279 tempitem.misc9 = 0;
9077 279 tempitem.misc10 = 0;
9078 279 tempitem.wpn = 0;
9079 279 tempitem.wpn2 = 0;
9080 279 tempitem.wpn3 = 0;
9081 279 tempitem.wpn4 = 0;
9082 279 tempitem.wpn5 = 0;
9083 279 tempitem.wpn6 = 0;
9084 279 tempitem.wpn7 = 0;
9085 279 tempitem.wpn8 = 0;
9086 279 tempitem.wpn9 = 0;
9087 279 tempitem.wpn10 = 0;
9088 279 break;
9089 }
9090 case itype_stompboots:
9091 {
9092 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9093 279 tempitem.misc1 = 0;
9094 279 tempitem.misc2 = 0;
9095 279 tempitem.misc3 = 0;
9096 279 tempitem.misc4 = 0;
9097 279 tempitem.misc5 = 0;
9098 279 tempitem.misc6 = 0;
9099 279 tempitem.misc7 = 0;
9100 279 tempitem.misc8 = 0;
9101 279 tempitem.misc9 = 0;
9102 279 tempitem.misc10 = 0;
9103 279 tempitem.wpn = 0;
9104 279 tempitem.wpn2 = 0;
9105 279 tempitem.wpn3 = 0;
9106 279 tempitem.wpn4 = 0;
9107 279 tempitem.wpn5 = 0;
9108 279 tempitem.wpn6 = 0;
9109 279 tempitem.wpn7 = 0;
9110 279 tempitem.wpn8 = 0;
9111 279 tempitem.wpn9 = 0;
9112 279 tempitem.wpn10 = 0;
9113 279 break;
9114 }
9115 case itype_whimsicalring:
9116 {
9117 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9118 279 tempitem.misc2 = 0;
9119 279 tempitem.misc3 = 0;
9120 279 tempitem.misc4 = 0;
9121 279 tempitem.misc5 = 0;
9122 279 tempitem.misc6 = 0;
9123 279 tempitem.misc7 = 0;
9124 279 tempitem.misc8 = 0;
9125 279 tempitem.misc9 = 0;
9126 279 tempitem.misc10 = 0;
9127 279 tempitem.wpn = 0;
9128 279 tempitem.wpn2 = 0;
9129 279 tempitem.wpn3 = 0;
9130 279 tempitem.wpn4 = 0;
9131 279 tempitem.wpn5 = 0;
9132 279 tempitem.wpn6 = 0;
9133 279 tempitem.wpn7 = 0;
9134 279 tempitem.wpn8 = 0;
9135 279 tempitem.wpn9 = 0;
9136 279 tempitem.wpn10 = 0;
9137 279 break;
9138 }
9139 case itype_perilring:
9140 {
9141 306 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9142 306 tempitem.misc2 = 0;
9143 306 tempitem.misc3 = 0;
9144 306 tempitem.misc4 = 0;
9145 306 tempitem.misc5 = 0;
9146 306 tempitem.misc6 = 0;
9147 306 tempitem.misc7 = 0;
9148 306 tempitem.misc8 = 0;
9149 306 tempitem.misc9 = 0;
9150 306 tempitem.misc10 = 0;
9151 306 tempitem.wpn = 0;
9152 306 tempitem.wpn2 = 0;
9153 306 tempitem.wpn3 = 0;
9154 306 tempitem.wpn4 = 0;
9155 306 tempitem.wpn5 = 0;
9156 306 tempitem.wpn6 = 0;
9157 306 tempitem.wpn7 = 0;
9158 306 tempitem.wpn8 = 0;
9159 306 tempitem.wpn9 = 0;
9160 306 tempitem.wpn10 = 0;
9161 306 break;
9162 }
9163 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9164 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9165 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9166 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9167 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9168 {
9169 10652 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9170 10652 tempitem.misc1 = 0;
9171 10652 tempitem.misc2 = 0;
9172 10652 tempitem.misc3 = 0;
9173 10652 tempitem.misc4 = 0;
9174 10652 tempitem.misc5 = 0;
9175 10652 tempitem.misc6 = 0;
9176 10652 tempitem.misc7 = 0;
9177 10652 tempitem.misc8 = 0;
9178 10652 tempitem.misc9 = 0;
9179 10652 tempitem.misc10 = 0;
9180 10652 tempitem.wpn = 0;
9181 10652 tempitem.wpn2 = 0;
9182 10652 tempitem.wpn3 = 0;
9183 10652 tempitem.wpn4 = 0;
9184 10652 tempitem.wpn5 = 0;
9185 10652 tempitem.wpn6 = 0;
9186 10652 tempitem.wpn7 = 0;
9187 10652 tempitem.wpn8 = 0;
9188 10652 tempitem.wpn9 = 0;
9189 10652 tempitem.wpn10 = 0;
9190 10652 break;
9191 }
9192 }
9193 72192 }
9194 //Port quest rules to items
9195
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version <= 31)
9196 {
9197
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 71897 times.
72192 if(tempitem.type == itype_bomb)
9198 {
9199
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 139 times.
295 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9200 139 else tempitem.flags &= ~ item_flag2;
9201 295 }
9202
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 71616 times.
71897 else if(tempitem.type == itype_sbomb)
9203 {
9204
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 123 times.
281 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9205 123 else tempitem.flags &= ~ item_flag2;
9206 281 }
9207
9208
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 70772 times.
71616 else if(tempitem.type == itype_brang)
9209 {
9210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9211 844 else tempitem.flags &= ~ item_flag4;
9212 844 }
9213
2/2
✓ Branch 0 taken 70475 times.
✓ Branch 1 taken 297 times.
70772 else if(tempitem.type == itype_wand)
9214 {
9215
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9216 279 else tempitem.flags &= ~ item_flag3;
9217 297 }
9218 72192 }
9219
9220 //Port quest rules to items
9221
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version <= 37)
9222 {
9223
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71910 times.
72192 if(tempitem.type == itype_flippers)
9224 {
9225
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 203 times.
282 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9226 203 else tempitem.flags &= ~ item_flag1;
9227 282 }
9228
2/2
✓ Branch 0 taken 54363 times.
✓ Branch 1 taken 17547 times.
71910 else if(tempitem.type == itype_sword)
9229 {
9230
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 17109 times.
17547 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9231 17109 else tempitem.flags &= ~ item_flag5;
9232 17547 }
9233
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 54066 times.
54363 else if(tempitem.type == itype_wand)
9234 {
9235
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 288 times.
297 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9236 288 else tempitem.flags &= ~ item_flag5;
9237 297 }
9238
4/4
✓ Branch 0 taken 53771 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 600 times.
✓ Branch 3 taken 53171 times.
54066 else if(tempitem.type == itype_book || tempitem.type == itype_candle)
9239 {
9240 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9241
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 520 times.
895 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9242 520 else tempitem.flags &= ~ item_flag3;
9243 895 }
9244 72192 }
9245
9246
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 38)
9247 {
9248
4/4
✓ Branch 0 taken 71348 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 70788 times.
72192 if(tempitem.type == itype_brang || tempitem.type == itype_hookshot)
9249 {
9250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9251 1404 else tempitem.flags &= ~item_flag4;
9252
9253
2/2
✓ Branch 0 taken 673 times.
✓ Branch 1 taken 731 times.
1404 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9254 731 else tempitem.flags &= ~(item_flag5|item_flag6);
9255 1404 }
9256
2/2
✓ Branch 0 taken 69957 times.
✓ Branch 1 taken 831 times.
70788 else if(tempitem.type == itype_arrow)
9257 {
9258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
831 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9259 831 else tempitem.flags &= ~item_flag4;
9260
9261
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 435 times.
831 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9262 435 else tempitem.flags |= item_flag2;
9263 831 }
9264 72192 }
9265
9266
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 39)
9267 {
9268
6/6
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 71618 times.
✓ Branch 3 taken 295 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 71018 times.
72192 if(tempitem.type == itype_divinefire || tempitem.type == itype_book || tempitem.type == itype_candle)
9269 {
9270
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1158 times.
1174 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9271 1158 else tempitem.flags &= ~item_flag5;
9272 1174 }
9273
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 70404 times.
71018 else if(tempitem.type == itype_potion)
9274 {
9275
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 452 times.
614 if(get_qr(qr_NONBUBBLEMEDICINE))
9276 {
9277 162 tempitem.flags &= ~(item_flag3|item_flag4);
9278 162 }
9279 else
9280 {
9281 452 tempitem.flags |= item_flag3;
9282
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 333 times.
452 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9283 333 else tempitem.flags &= ~item_flag4;
9284 }
9285 614 }
9286
2/2
✓ Branch 0 taken 69846 times.
✓ Branch 1 taken 558 times.
70404 else if(tempitem.type == itype_triforcepiece)
9287 {
9288
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 474 times.
558 if(get_qr(qr_NONBUBBLETRIFORCE))
9289 {
9290 84 tempitem.flags |= item_flag3;
9291
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9292 28 else tempitem.flags &= ~item_flag4;
9293 84 }
9294 else
9295 {
9296 474 tempitem.flags &= ~(item_flag3|item_flag4);
9297 }
9298 558 }
9299 72192 }
9300
9301
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 40)
9302 {
9303
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 917 times.
✓ Branch 2 taken 306 times.
✓ Branch 3 taken 70969 times.
72192 if(tempitem.type == itype_ring || tempitem.type == itype_perilring)
9304 {
9305
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 934 times.
1223 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9306 934 else tempitem.flags &= ~item_flag1;
9307 1223 }
9308
8/8
✓ Branch 0 taken 70369 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 52822 times.
✓ Branch 3 taken 17547 times.
✓ Branch 4 taken 52525 times.
✓ Branch 5 taken 297 times.
✓ Branch 6 taken 279 times.
✓ Branch 7 taken 52246 times.
70969 else if(tempitem.type == itype_candle || tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_cbyrna)
9309 {
9310
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18615 times.
18723 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9311 18615 else tempitem.flags &= ~item_flag8;
9312 18723 }
9313
6/6
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
✓ Branch 2 taken 54348 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 54066 times.
72192 if(tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_hammer)
9314 {
9315
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 18048 times.
18126 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9316 18048 else tempitem.flags &= ~item_flag7;
9317 18126 }
9318
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 279 times.
54066 else if(tempitem.type == itype_cbyrna)
9319 {
9320 279 tempitem.flags |= item_flag7;
9321 279 }
9322 72192 }
9323
9324
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 41 )
9325 {
9326
2/2
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
72192 if(tempitem.type == itype_sword)
9327 {
9328
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 17311 times.
17547 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9329 17311 else tempitem.flags &= ~item_flag9;
9330
9331
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17119 times.
17547 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9332 17119 else tempitem.flags &= ~item_flag10;
9333 17547 }
9334 72192 }
9335
9336
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 42 )
9337 {
9338
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 71895 times.
72192 if(tempitem.type == itype_wand)
9339 {
9340
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9341 279 else tempitem.flags &= ~item_flag3;
9342
9343 297 tempitem.flags &= ~item_flag6;
9344 297 }
9345
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71613 times.
71895 else if(tempitem.type == itype_hammer)
9346 {
9347 282 tempitem.flags &= ~item_flag3;
9348 282 }
9349
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 71334 times.
71613 else if(tempitem.type == itype_cbyrna)
9350 {
9351 279 tempitem.flags |= item_flag3;
9352
9353 279 tempitem.flags &= ~item_flag6;
9354 279 }
9355
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 17547 times.
71334 else if(tempitem.type == itype_sword)
9356 {
9357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17547 times.
17547 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9358 17547 else tempitem.flags &= ~item_flag6;
9359 17547 }
9360 72192 }
9361
9362
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 43 )
9363 {
9364
2/2
✓ Branch 0 taken 71865 times.
✓ Branch 1 taken 327 times.
72192 if(tempitem.type == itype_whistle)
9365 {
9366
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 317 times.
327 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9367 317 else tempitem.flags &= ~item_flag3;
9368 327 }
9369 72192 }
9370
9371
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 45 )
9372 {
9373
2/2
✓ Branch 0 taken 71910 times.
✓ Branch 1 taken 282 times.
72192 if(tempitem.type == itype_flippers)
9374 {
9375 282 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9376 282 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9377 282 }
9378 72192 }
9379
9380
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 46 )
9381 {
9382
2/2
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
72192 if(tempitem.type == itype_raft)
9383 {
9384 279 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9385 279 }
9386 72192 }
9387
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 34 ) //! set the default counter for older quests.
9388 {
9389
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 72076 times.
72192 if ( (tempitem.flags & item_rupee_magic) )
9390 {
9391 116 tempitem.cost_counter[0] = 1;
9392 116 }
9393 else
9394 {
9395
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 29580 times.
72076 if(get_qr(qr_ENABLEMAGIC))
9396 42496 tempitem.cost_counter[0] = 4;
9397 else
9398 {
9399 29580 tempitem.cost_amount[0] = 0;
9400 29580 tempitem.cost_counter[0] = -1;
9401 }
9402 }
9403 72192 }
9404
9405
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 35 ) //new Lens of Truth flags
9406 {
9407
2/2
✓ Branch 0 taken 71937 times.
✓ Branch 1 taken 255 times.
72192 if ( tempitem.type == itype_lens )
9408 {
9409
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 10 times.
255 if ( get_qr(qr_RAFTLENS) )
9410 {
9411 10 tempitem.flags |= item_flag4;
9412 10 }
9413
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 166 times.
255 if ( get_qr(qr_LENSHINTS) )
9414 {
9415 166 tempitem.flags |= item_flag1;
9416 166 }
9417
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 13 times.
255 if ( get_qr(qr_LENSSEESENEMIES) )
9418 {
9419 13 tempitem.flags |= item_flag5;
9420 13 }
9421 255 }
9422 72192 }
9423
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9424 {
9425
2/2
✓ Branch 0 taken 577536 times.
✓ Branch 1 taken 72192 times.
649728 for ( int32_t q = 0; q < 8; q++ )
9426 {
9427 577536 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9428 577536 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9429 577536 tempitem.sprite_initiald[q] = 0;
9430 577536 }
9431 72192 tempitem.sprite_script = 0;
9432 72192 }
9433
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9434 {
9435 72192 tempitem.pickupflag = 0;
9436 72192 }
9437
9438
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 51 )
9439 {
9440
2/2
✓ Branch 0 taken 71592 times.
✓ Branch 1 taken 600 times.
72192 if( tempitem.type == itype_candle )
9441 {
9442 600 tempitem.misc4 = 50; //Step speed
9443 600 }
9444 72192 }
9445
9446
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 52 )
9447 {
9448
2/2
✓ Branch 0 taken 71334 times.
✓ Branch 1 taken 858 times.
72192 if( tempitem.type == itype_shield )
9449 858 tempitem.flags |= item_flag1; //'Block Front' flag
9450 72192 }
9451
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if(s_version < 53)
9452 {
9453
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 70785 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 281 times.
72192 switch(tempitem.type)
9454 {
9455 case itype_arrow:
9456 831 tempitem.cost_counter[1] = crARROWS;
9457 831 tempitem.cost_amount[1] = 1;
9458 831 break;
9459 case itype_bomb:
9460 295 tempitem.cost_counter[1] = crBOMBS;
9461 295 tempitem.cost_amount[1] = 1;
9462 295 break;
9463 case itype_sbomb:
9464 281 tempitem.cost_counter[1] = crSBOMBS;
9465 281 tempitem.cost_amount[1] = 1;
9466 281 break;
9467 default:
9468 70785 tempitem.cost_counter[1] = crNONE;
9469 70785 tempitem.cost_amount[1] = 0;
9470 70785 }
9471 72192 tempitem.magiccosttimer[1] = 0;
9472 72192 }
9473
2/2
✓ Branch 0 taken 47872 times.
✓ Branch 1 taken 75008 times.
122880 if( s_version < 54 )
9474 {
9475
2/2
✓ Branch 0 taken 74713 times.
✓ Branch 1 taken 295 times.
75008 if( tempitem.type == itype_flippers )
9476 295 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9477 75008 }
9478
2/2
✓ Branch 0 taken 47872 times.
✓ Branch 1 taken 75008 times.
122880 if(s_version < 55)
9479 {
9480
3/3
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 73848 times.
75008 switch(tempitem.type)
9481 {
9482 case itype_spinscroll:
9483 case itype_quakescroll:
9484 580 tempitem.usesound2 = WAV_ZN1CHARGE;
9485 580 break;
9486 case itype_spinscroll2:
9487 case itype_quakescroll2:
9488 580 tempitem.usesound2 = WAV_ZN1CHARGE2;
9489 580 break;
9490 }
9491 75008 }
9492
2/2
✓ Branch 0 taken 47872 times.
✓ Branch 1 taken 75008 times.
122880 if(s_version < 56)
9493 {
9494
4/4
✓ Branch 0 taken 73786 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 306 times.
75008 switch(tempitem.type)
9495 {
9496 case itype_divinefire:
9497
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 11 times.
290 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9498
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9499 290 tempitem.flags |= item_flag11; //Divine Fire
9500 290 break;
9501 case itype_candle:
9502
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 314 times.
626 SETFLAG(tempitem.flags, item_flag9, tempitem.level > 1); //Strong Fire
9503 626 tempitem.flags &= ~item_flag10; //Magic Fire
9504 626 tempitem.flags &= ~item_flag11; //Divine Fire
9505 626 break;
9506 case itype_book:
9507 306 tempitem.flags |= item_flag9; //Strong Fire
9508 306 tempitem.flags |= item_flag10; //Magic Fire
9509 306 tempitem.flags &= ~item_flag11; //Divine Fire
9510 306 break;
9511 }
9512 75008 }
9513
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 88320 times.
122880 if (s_version < 61)
9514 {
9515
2/2
✓ Branch 0 taken 69510 times.
✓ Branch 1 taken 18810 times.
88320 switch (tempitem.type)
9516 {
9517 case itype_sword:
9518 18810 tempitem.usesound2 = WAV_BEAM;
9519 18810 break;
9520 }
9521 88320 }
9522
9523
9524
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 111892 times.
122880 if(tempitem.level==0) // Always do this
9525 10988 tempitem.level=1;
9526
9527 122880 itemsbuf[i] = tempitem;
9528 122880 }
9529
9530 480 return 0;
9531 481 }
9532
9533 static bool did_init_def_items = false;
9534 245626 void init_def_items()
9535 {
9536
2/2
✓ Branch 0 taken 245255 times.
✓ Branch 1 taken 371 times.
245626 if(did_init_def_items) return;
9537 371 did_init_def_items = true;
9538 371 default_items[3].cost_counter[1] = crBOMBS;
9539 371 default_items[13].cost_counter[1] = crARROWS;
9540 371 default_items[14].cost_counter[1] = crARROWS;
9541 371 default_items[48].cost_counter[1] = crSBOMBS;
9542 371 default_items[57].cost_counter[1] = crARROWS;
9543 245626 }
9544 245626 void reset_itembuf(itemdata *item, int32_t id)
9545 {
9546 245626 init_def_items();
9547
2/2
✓ Branch 0 taken 103169 times.
✓ Branch 1 taken 142457 times.
245626 if(id<iLast)
9548 {
9549 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9550 142457 word tile = item->tile;
9551 142457 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9552 142457 int32_t ltm = item->ltm;
9553
9554 142457 *item = default_items[id];
9555 142457 item->tile = tile;
9556 142457 item->misc_flags = miscs;
9557 142457 item->csets = cset;
9558 142457 item->frames = frames;
9559 142457 item->speed = speed;
9560 142457 item->delay = delay;
9561 142457 item->ltm = ltm;
9562 142457 }
9563 245626 }
9564
9565 101632 void reset_itemname(int32_t id)
9566 {
9567 101632 sprintf(item_string[id],"zz%03d",id);
9568
9569
2/2
✓ Branch 0 taken 44861 times.
✓ Branch 1 taken 56771 times.
101632 if(id < iLast)
9570 56771 strcpy(item_string[id],old_item_string[id]);
9571 101632 }
9572
9573 481 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9574 {
9575
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9576
9577 481 word weapons_to_read=MAXWPNS;
9578 int32_t dummy;
9579 byte padding;
9580 wpndata tempweapon;
9581 481 word s_version=0;
9582
9583
9584
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(Header->zelda_version < 0x186)
9585 {
9586 6 weapons_to_read=64;
9587 6 }
9588
9589
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(Header->zelda_version < 0x185)
9590 {
9591 6 weapons_to_read=32;
9592 6 }
9593
9594
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(Header->zelda_version > 0x192)
9595 {
9596 457 weapons_to_read=0;
9597
9598 //section version info
9599
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
9600 {
9601 return qe_invalid;
9602 }
9603
9604 457 FFCore.quest_format[vWeaponSprites] = s_version;
9605
9606
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!read_deprecated_section_cversion(f))
9607 {
9608 return qe_invalid;
9609 }
9610
9611 //section size
9612
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
9613 {
9614 return qe_invalid;
9615 }
9616
9617 //finally... section data
9618
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&weapons_to_read,f))
9619 {
9620 return qe_invalid;
9621 }
9622
9623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (weapons_to_read > MAXWPNS)
9624 {
9625 return qe_invalid;
9626 }
9627 457 }
9628
9629
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 83 times.
481 if(s_version>2)
9630 {
9631
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i=0; i<weapons_to_read; i++)
9632 {
9633 char tempname[64];
9634
9635
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!pfread(tempname, 64, f))
9636 {
9637 return qe_invalid;
9638 }
9639
9640 101888 weapon_string[i][0] = '\0';
9641 101888 strncat(weapon_string[i], tempname, 64 - 1);
9642 101888 }
9643
9644
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version<4)
9645 {
9646 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9647 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9648 }
9649
9650
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version<5)
9651 {
9652 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9653 }
9654
9655 /*
9656 if (s_version<6)
9657 {
9658 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9659 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9660 }
9661 */
9662 398 }
9663
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9664 {
9665
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9666 20992 reset_weaponname(i);
9667 82 }
9668
9669
2/2
✓ Branch 0 taken 110700 times.
✓ Branch 1 taken 481 times.
111181 for(int32_t i=0; i<weapons_to_read; i++)
9670 {
9671 110700 word oldtile = 0;
9672
2/2
✓ Branch 0 taken 49408 times.
✓ Branch 1 taken 61292 times.
110700 if (s_version < 8)
9673 {
9674
1/2
✓ Branch 0 taken 61292 times.
✗ Branch 1 not taken.
61292 if (!p_igetw(&oldtile, f))
9675 return qe_invalid;
9676 61292 }
9677
9678
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.misc,f))
9679 {
9680 return qe_invalid;
9681 }
9682
9683
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.csets,f))
9684 {
9685 return qe_invalid;
9686 }
9687
9688
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.frames,f))
9689 {
9690 return qe_invalid;
9691 }
9692
9693
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.speed,f))
9694 {
9695 return qe_invalid;
9696 }
9697
9698
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.type,f))
9699 {
9700 return qe_invalid;
9701 }
9702
9703
2/2
✓ Branch 0 taken 60012 times.
✓ Branch 1 taken 50688 times.
110700 if ( s_version >= 7 )
9704 {
9705
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempweapon.script,f))
9706 {
9707 return qe_invalid;
9708 }
9709
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempweapon.tile,f))
9710 {
9711 return qe_invalid;
9712 }
9713 50688 }
9714
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 60012 times.
110700 if ( s_version < 7 )
9715 {
9716 60012 tempweapon.tile = oldtile;
9717 60012 }
9718
9719
2/2
✓ Branch 0 taken 105900 times.
✓ Branch 1 taken 4800 times.
110700 if(Header->zelda_version < 0x193)
9720 {
9721
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9722 {
9723 return qe_invalid;
9724 }
9725 4800 }
9726
9727
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 8812 times.
110700 if(s_version < 6)
9728 {
9729
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9730 {
9731 18 tempweapon.misc |= WF_BEHIND;
9732 18 }
9733 else
9734 8794 tempweapon.misc &= ~WF_BEHIND;
9735 8812 }
9736
9737
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 110444 times.
110700 if (!should_skip)
9738 110444 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9739 110700 }
9740
9741
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (should_skip)
9742 1 return 0;
9743
9744
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<2)
9745 {
9746 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9747 82 }
9748
9749
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<5)
9750 {
9751 82 wpnsbuf[iwQuarterHearts].tile=1;
9752 82 wpnsbuf[iwQuarterHearts].csets=1;
9753 82 }
9754
9755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(Header->zelda_version < 0x176)
9756 {
9757 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9758 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9759 itemsbuf[iMisc1].clear();
9760 itemsbuf[iMisc2].clear();
9761 }
9762
9763
3/4
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
485 if((Header->zelda_version < 0x192)||
9764
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 457 times.
462 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9765 {
9766 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9767 18 }
9768
9769
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if((Header->zelda_version < 0x210))
9770 {
9771 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9772 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9773 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9774 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9775 23 }
9776
9777 480 return 0;
9778 481 }
9779
9780 221192 static void guy_update_firesfx(guydata& tempguy)
9781 {
9782 221192 tempguy.firesfx = 0;
9783
2/2
✓ Branch 0 taken 6415 times.
✓ Branch 1 taken 214777 times.
221192 if (tempguy.type == eeWIZZ)
9784 {
9785
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 971 times.
✓ Branch 2 taken 3920 times.
✓ Branch 3 taken 826 times.
✓ Branch 4 taken 698 times.
6415 switch (tempguy.attributes[1])
9786 {
9787 case 0: // normal weapon
9788 3920 tempguy.firesfx = WAV_WAND;
9789 3920 break;
9790 case 1: // 8 shots
9791
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 744 times.
826 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9792 else
9793 {
9794
3/8
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
744 switch (tempguy.weapon)
9795 {
9796 case ewFireTrail:
9797 case ewFlame:
9798 case ewFlame2Trail:
9799 case ewFlame2:
9800 640 tempguy.firesfx = WAV_FIRE;
9801 640 break;
9802 case ewWind:
9803 case ewMagic:
9804 88 tempguy.firesfx = WAV_WAND;
9805 88 break;
9806 case ewIce:
9807 tempguy.firesfx = WAV_ZN1ICE;
9808 break;
9809 case ewRock:
9810 tempguy.firesfx = WAV_ZN1ROCK;
9811 break;
9812 case ewFireball2:
9813 case ewFireball:
9814 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9815 16 break;
9816 case ewBrang:
9817 tempguy.firesfx = WAV_BRANG;
9818 break;
9819 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9820 tempguy.firesfx = WAV_BOMB;
9821 break;
9822 default:
9823 tempguy.firesfx = 0;
9824 break;
9825 }
9826 744 break;
9827 }
9828 case 2: // Summon
9829 1053 tempguy.firesfx = WAV_FIRE;
9830 1053 break;
9831 case 3: // Summon Layer
9832 698 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9833 698 break;
9834 }
9835 6415 }
9836 else
9837 {
9838
6/6
✓ Branch 0 taken 162157 times.
✓ Branch 1 taken 52620 times.
✓ Branch 2 taken 41824 times.
✓ Branch 3 taken 203981 times.
✓ Branch 4 taken 47224 times.
✓ Branch 5 taken 47220 times.
214777 if ((tempguy.type == eeWALK || tempguy.type == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9839 {
9840 94444 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9841 94444 }
9842 else
9843 {
9844
7/8
✓ Branch 0 taken 9591 times.
✓ Branch 1 taken 2351 times.
✓ Branch 2 taken 1796 times.
✓ Branch 3 taken 12791 times.
✓ Branch 4 taken 171241 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3951 times.
✓ Branch 7 taken 2260 times.
203981 switch (tempguy.weapon)
9845 {
9846 case ewFireTrail:
9847 case ewFlame:
9848 case ewFlame2Trail:
9849 case ewFlame2:
9850 9591 tempguy.firesfx = WAV_FIRE;
9851 9591 break;
9852 case ewWind:
9853 case ewMagic:
9854 1796 tempguy.firesfx = WAV_WAND;
9855 1796 break;
9856 case ewIce:
9857 tempguy.firesfx = WAV_ZN1ICE;
9858 break;
9859 case ewRock:
9860 3951 tempguy.firesfx = WAV_ZN1ROCK;
9861 3951 break;
9862 case ewFireball2:
9863 case ewFireball:
9864 12791 tempguy.firesfx = WAV_ZN1FIREBALL;
9865 12791 break;
9866 case ewBrang:
9867 2260 tempguy.firesfx = WAV_BRANG;
9868 2260 break;
9869 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9870 2351 tempguy.firesfx = WAV_BOMB;
9871 2351 break;
9872 default:
9873 171241 tempguy.firesfx = 0;
9874 171241 break;
9875 }
9876 }
9877 }
9878 210400 }
9879
9880 210400 static void guy_update_weaponflags(guydata& tempguy)
9881 {
9882 210400 tempguy.weap_data.unblockable = 0;
9883 210400 tempguy.weap_data.moveflags = move_none;
9884
4/4
✓ Branch 0 taken 203892 times.
✓ Branch 1 taken 6508 times.
✓ Branch 2 taken 2996 times.
✓ Branch 3 taken 200896 times.
210400 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9885 9504 tempguy.weap_data.moveflags |= (move_obeys_grav | move_can_pitfall);
9886 210400 tempguy.weap_data.override_flags = 0;
9887 210400 tempguy.weap_data.hxofs = 0;
9888 210400 tempguy.weap_data.hyofs = 0;
9889 210400 tempguy.weap_data.hxsz = 0;
9890 210400 tempguy.weap_data.hysz = 0;
9891 210400 tempguy.weap_data.hzsz = 0;
9892 210400 tempguy.weap_data.xofs = 0;
9893 210400 tempguy.weap_data.yofs = 0;
9894 210400 tempguy.weap_data.tilew = 0;
9895 210400 tempguy.weap_data.tileh = 0;
9896
5/5
✓ Branch 0 taken 2500 times.
✓ Branch 1 taken 169270 times.
✓ Branch 2 taken 18463 times.
✓ Branch 3 taken 12807 times.
✓ Branch 4 taken 7360 times.
210400 switch (tempguy.weapon)
9897 {
9898 case ewFireball: case ewFireball2:
9899 12807 tempguy.weap_data.step = 1.75_zf;
9900 12807 break;
9901 case ewSword: case ewLitBomb: case ewLitSBomb:
9902 case ewRock: case ewMagic: case ewWind:
9903 18463 tempguy.weap_data.step = 3_zf;
9904 18463 break;
9905 case ewArrow:
9906 2500 tempguy.weap_data.step = 2_zf;
9907 2500 break;
9908 case ewFlame: case ewFlame2:
9909 7360 tempguy.weap_data.step = 1_zf;
9910 7360 break;
9911 default:
9912 169270 tempguy.weap_data.step = 0_zf;
9913 169270 break;
9914 }
9915
2/2
✓ Branch 0 taken 1052000 times.
✓ Branch 1 taken 210400 times.
1262400 for (int q = 0; q < WPNSPR_MAX; ++q)
9916 {
9917 1052000 tempguy.weap_data.burnsprs[q] = 0;
9918 1052000 tempguy.weap_data.light_rads[q] = 0;
9919 1052000 }
9920 210400 }
9921
9922 210400 static void guy_update_weaponspecialsfx(guydata& tempguy)
9923 {
9924
3/3
✓ Branch 0 taken 2260 times.
✓ Branch 1 taken 205734 times.
✓ Branch 2 taken 2406 times.
210400 switch (tempguy.weapon)
9925 {
9926 case ewBrang:
9927 2260 tempguy.specialsfx = WAV_BRANG;
9928 2260 break;
9929 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9930 2406 tempguy.specialsfx = WAV_BOMB;
9931 2406 break;
9932 default:
9933 205734 tempguy.specialsfx = 0;
9934 205734 break;
9935 }
9936 210400 }
9937
9938 480 void init_guys(int32_t guyversion)
9939 {
9940
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<MAXGUYS; i++)
9941 {
9942 245760 guysbuf[i] = default_guys[0];
9943 245760 }
9944
9945
2/2
✓ Branch 0 taken 84960 times.
✓ Branch 1 taken 480 times.
85440 for(int32_t i=0; i<OLDMAXGUYS; i++)
9946 {
9947 84960 guysbuf[i] = default_guys[i];
9948
2/2
✓ Branch 0 taken 84000 times.
✓ Branch 1 taken 960 times.
84960 guysbuf[i].spr_shadow = (guysbuf[i].type==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9949 84960 guysbuf[i].spr_death = iwDeath;
9950 84960 guysbuf[i].spr_spawn = iwSpawn;
9951 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9952
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 70446 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
84960 if(guyversion<=3 && i==ePATRABS)
9953 {
9954 82 guysbuf[i].bosspal=spDIG;
9955 82 guysbuf[i].cset=14;
9956 82 guysbuf[i].attributes[8] = 14;
9957 82 }
9958
9959
2/2
✓ Branch 0 taken 70446 times.
✓ Branch 1 taken 14514 times.
84960 if(guyversion<=3)
9960 {
9961 // Rope/Ghini Flash rules
9962
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9963 {
9964
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9965 {
9966 59 guysbuf[i].flags &= ~guy_flashing;
9967 59 }
9968 10443 }
9969
9970
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9971 {
9972
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9973 {
9974 72 guysbuf[i].flags &= ~guy_flashing;
9975 72 }
9976 2124 }
9977
9978
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9979 {
9980
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9981 {
9982 4 guysbuf[i].flags |= guy_blinking;
9983 4 }
9984
9985
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9986 {
9987 38 guysbuf[i].flags |= guy_transparent;
9988 38 }
9989 82 }
9990
9991
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9992 {
9993 164 guysbuf[i].flags |= guy_ignore_kill_all;
9994 164 }
9995 14514 }
9996
9997 // Darknut fix
9998
10/10
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 84000 times.
✓ Branch 3 taken 480 times.
✓ Branch 4 taken 83520 times.
✓ Branch 5 taken 480 times.
✓ Branch 6 taken 83040 times.
✓ Branch 7 taken 480 times.
✓ Branch 8 taken 480 times.
✓ Branch 9 taken 82560 times.
84960 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9999 {
10000
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 410 times.
2400 if(get_qr(qr_NEWENEMYTILES))
10001 {
10002 1990 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
10003 1990 guysbuf[i].s_width=guysbuf[i].e_width;
10004 1990 guysbuf[i].s_height=guysbuf[i].e_height;
10005 1990 }
10006 410 else guysbuf[i].s_tile=860;
10007
10008
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2080 times.
2400 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
10009 2080 guysbuf[i].flags &= ~guy_bkshield;
10010 else
10011 320 guysbuf[i].flags |= guy_bkshield;
10012 2400 }
10013
10014
4/4
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 84910 times.
✓ Branch 3 taken 50 times.
84960 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
10015 {
10016 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
10017 50 }
10018
10019 84960 guy_update_firesfx(guysbuf[i]);
10020 84960 guy_update_weaponflags(guysbuf[i]);
10021 84960 guy_update_weaponspecialsfx(guysbuf[i]);
10022 84960 }
10023 480 }
10024
10025 20992 void reset_weaponname(int32_t i)
10026 {
10027
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
10028 {
10029 7216 strcpy(weapon_string[i],old_weapon_string[i]);
10030 7216 }
10031 else
10032 13776 sprintf(weapon_string[i],"zz%03d",i);
10033 20992 }
10034
10035 480 void init_item_drop_sets()
10036 {
10037
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
10038 {
10039 // item_drop_sets[i] = default_item_drop_sets[0];
10040 122880 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
10041 122880 }
10042
10043
2/2
✓ Branch 0 taken 6240 times.
✓ Branch 1 taken 480 times.
6720 for(int32_t i=0; i<isMAX; i++)
10044 {
10045 6240 item_drop_sets[i] = default_item_drop_sets[i];
10046
10047 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
10048
2/2
✓ Branch 0 taken 62400 times.
✓ Branch 1 taken 6240 times.
68640 for(int32_t j=0; j<10; ++j)
10049 {
10050 62400 int32_t it = item_drop_sets[i].item[j];
10051
10052
3/4
✓ Branch 0 taken 43884 times.
✓ Branch 1 taken 18516 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2832 times.
62400 if((itemsbuf[it].type == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
10053
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 41052 times.
43884 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
10054 {
10055 2832 item_drop_sets[i].chance[j+1]=0;
10056 2832 }
10057
4/4
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 57648 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1776 times.
59568 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
10058 {
10059 144 item_drop_sets[i].chance[j+1]=0;
10060 144 }
10061
10062 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
10063
2/2
✓ Branch 0 taken 62376 times.
✓ Branch 1 taken 24 times.
62400 if(itemsbuf[it].type == itype_misc)
10064 {
10065 // If a non-gameplay item was selected, then item drop was aborted.
10066 // Reflect this by increasing the 'Nothing' chance accordingly.
10067 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
10068 24 item_drop_sets[i].chance[j+1]=0;
10069 24 }
10070 62400 }
10071 6240 }
10072 480 }
10073
10074 480 void init_favorites()
10075 {
10076
2/2
✓ Branch 0 taken 604800 times.
✓ Branch 1 taken 480 times.
605280 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
10077 {
10078 604800 favorite_combos[i]=-1;
10079 604800 }
10080 480 }
10081
10082 767 int32_t init_combo_classes()
10083 {
10084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 767 times.
767 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10085
2/2
✓ Branch 0 taken 141128 times.
✓ Branch 1 taken 767 times.
141895 for(int32_t i=0; i<cMAX; i++)
10086 {
10087 141128 combo_class_buf[i] = default_combo_classes[i];
10088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141128 times.
141128 if ( char const* nm = zi->getComboTypeName(i) )
10089 {
10090 141128 size_t len = strlen(nm);
10091
2/2
✓ Branch 0 taken 9032192 times.
✓ Branch 1 taken 141128 times.
9173320 for ( size_t q = 0; q < 64; q++ )
10092 {
10093
2/2
✓ Branch 0 taken 2068599 times.
✓ Branch 1 taken 6963593 times.
9032192 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10094 9032192 }
10095 141128 }
10096 141128 }
10097
10098 767 return 0;
10099 }
10100
10101 305 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
10102 {
10103
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 259 times.
305 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
10104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if (should_skip) return 0;
10105
10106
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 assert(v_herosprites < 6);
10107
10108 305 zinit.hero_swim_speed=67; //default
10109 305 setupherotiles(zinit.heroAnimationStyle);
10110 305 setupherodefenses();
10111 305 setupherooffsets();
10112
10113
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 200 times.
305 if(v_herosprites>=0)
10114 {
10115 word tile, tile2;
10116 byte flip, extend, dummy_byte;
10117
10118
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10119 {
10120
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10121 {
10122 return qe_invalid;
10123 }
10124
10125
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10126 {
10127 return qe_invalid;
10128 }
10129
10130
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10131 {
10132 return qe_invalid;
10133 }
10134
10135 800 walkspr[i][spr_tile]=(int32_t)tile;
10136 800 walkspr[i][spr_flip]=(int32_t)flip;
10137 800 walkspr[i][spr_extend]=(int32_t)extend;
10138 800 }
10139
10140
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10141 {
10142
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10143 {
10144 return qe_invalid;
10145 }
10146
10147
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10148 {
10149 return qe_invalid;
10150 }
10151
10152
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10153 {
10154 return qe_invalid;
10155 }
10156
10157 800 stabspr[i][spr_tile]=(int32_t)tile;
10158 800 stabspr[i][spr_flip]=(int32_t)flip;
10159 800 stabspr[i][spr_extend]=(int32_t)extend;
10160 800 }
10161
10162
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10163 {
10164
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10165 {
10166 return qe_invalid;
10167 }
10168
10169
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10170 {
10171 return qe_invalid;
10172 }
10173
10174
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10175 {
10176 return qe_invalid;
10177 }
10178
10179 800 slashspr[i][spr_tile]=(int32_t)tile;
10180 800 slashspr[i][spr_flip]=(int32_t)flip;
10181 800 slashspr[i][spr_extend]=(int32_t)extend;
10182 800 }
10183
10184
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10185 {
10186
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10187 {
10188 return qe_invalid;
10189 }
10190
10191
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10192 {
10193 return qe_invalid;
10194 }
10195
10196
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10197 {
10198 return qe_invalid;
10199 }
10200
10201 800 floatspr[i][spr_tile]=(int32_t)tile;
10202 800 floatspr[i][spr_flip]=(int32_t)flip;
10203 800 floatspr[i][spr_extend]=(int32_t)extend;
10204 800 }
10205
10206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>1)
10207 {
10208
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10209 {
10210
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10211 {
10212 return qe_invalid;
10213 }
10214
10215
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10216 {
10217 return qe_invalid;
10218 }
10219
10220
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10221 {
10222 return qe_invalid;
10223 }
10224
10225 800 swimspr[i][spr_tile]=(int32_t)tile;
10226 800 swimspr[i][spr_flip]=(int32_t)flip;
10227 800 swimspr[i][spr_extend]=(int32_t)extend;
10228 800 }
10229 200 }
10230
10231
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10232 {
10233
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10234 {
10235 return qe_invalid;
10236 }
10237
10238
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10239 {
10240 return qe_invalid;
10241 }
10242
10243
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10244 {
10245 return qe_invalid;
10246 }
10247
10248 800 divespr[i][spr_tile]=(int32_t)tile;
10249 800 divespr[i][spr_flip]=(int32_t)flip;
10250 800 divespr[i][spr_extend]=(int32_t)extend;
10251 800 }
10252
10253
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10254 {
10255
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10256 {
10257 return qe_invalid;
10258 }
10259
10260
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10261 {
10262 return qe_invalid;
10263 }
10264
10265
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10266 {
10267 return qe_invalid;
10268 }
10269
10270 800 poundspr[i][spr_tile]=(int32_t)tile;
10271 800 poundspr[i][spr_flip]=(int32_t)flip;
10272 800 poundspr[i][spr_extend]=(int32_t)extend;
10273 800 }
10274
10275
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&tile,f))
10276 {
10277 return qe_invalid;
10278 }
10279
10280 200 flip=0;
10281
10282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>0)
10283 {
10284
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&flip,f))
10285 {
10286 return qe_invalid;
10287 }
10288 200 }
10289
10290
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&extend,f))
10291 {
10292 return qe_invalid;
10293 }
10294
10295 200 castingspr[spr_tile]=(int32_t)tile;
10296 200 castingspr[spr_flip]=(int32_t)flip;
10297 200 castingspr[spr_extend]=(int32_t)extend;
10298
10299
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(v_herosprites>0)
10300 {
10301 200 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10302
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 200 times.
600 for(int32_t i=0; i<2; i++)
10303 {
10304
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 400 times.
1200 for(int32_t j=0; j<num_holdsprs; j++)
10305 {
10306
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10307 {
10308 return qe_invalid;
10309 }
10310
10311
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10312 {
10313 return qe_invalid;
10314 }
10315
10316
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10317 {
10318 return qe_invalid;
10319 }
10320
10321 800 holdspr[i][j][spr_tile]=(int32_t)tile;
10322 800 holdspr[i][j][spr_flip]=(int32_t)flip;
10323 800 holdspr[i][j][spr_extend]=(int32_t)extend;
10324 800 }
10325 400 }
10326 200 }
10327 else
10328 {
10329 for(int32_t i=0; i<2; i++)
10330 {
10331 if(!p_igetw(&tile,f))
10332 {
10333 return qe_invalid;
10334 }
10335
10336 if(!p_igetw(&tile2,f))
10337 {
10338 return qe_invalid;
10339 }
10340
10341 if(!p_getc(&extend,f))
10342 {
10343 return qe_invalid;
10344 }
10345
10346 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10347 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10348 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10349 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10350 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10351 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10352 }
10353 }
10354
10355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>2)
10356 {
10357
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10358 {
10359
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10360 {
10361 return qe_invalid;
10362 }
10363
10364
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10365 {
10366 return qe_invalid;
10367 }
10368
10369
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10370 {
10371 return qe_invalid;
10372 }
10373
10374 800 jumpspr[i][spr_tile]=(int32_t)tile;
10375 800 jumpspr[i][spr_flip]=(int32_t)flip;
10376 800 jumpspr[i][spr_extend]=(int32_t)extend;
10377 800 }
10378 200 }
10379
10380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>3)
10381 {
10382
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10383 {
10384
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10385 {
10386 return qe_invalid;
10387 }
10388
10389
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10390 {
10391 return qe_invalid;
10392 }
10393
10394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_getc(&extend,f))
10395 {
10396 return qe_invalid;
10397 }
10398
10399 800 chargespr[i][spr_tile]=(int32_t)tile;
10400 800 chargespr[i][spr_flip]=(int32_t)flip;
10401 800 chargespr[i][spr_extend]=(int32_t)extend;
10402 800 }
10403 200 }
10404
10405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>4)
10406 {
10407
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&dummy_byte,f))
10408 {
10409 return qe_invalid;
10410 }
10411
10412 200 zinit.hero_swim_speed=(byte)dummy_byte;
10413 200 }
10414
10415 200 memset(frozenspr, 0, sizeof(frozenspr));
10416 200 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10417 200 memset(onfirespr, 0, sizeof(onfirespr));
10418 200 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10419 200 memset(diggingspr, 0, sizeof(diggingspr));
10420 200 memset(usingrodspr, 0, sizeof(usingrodspr));
10421 200 memset(usingcanespr, 0, sizeof(usingcanespr));
10422 200 memset(pushingspr, 0, sizeof(pushingspr));
10423 200 memset(liftingspr, 0, sizeof(liftingspr));
10424 200 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10425 200 memset(stunnedspr, 0, sizeof(stunnedspr));
10426 200 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10427 200 memset(fallingspr, 0, sizeof(fallingspr));
10428 200 memset(shockedspr, 0, sizeof(shockedspr));
10429 200 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10430 200 memset(pullswordspr, 0, sizeof(pullswordspr));
10431 200 memset(readingspr, 0, sizeof(readingspr));
10432 200 memset(slash180spr, 0, sizeof(slash180spr));
10433 200 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10434 200 memset(dashspr, 0, sizeof(dashspr));
10435 200 memset(bonkspr, 0, sizeof(bonkspr));
10436 200 memset(medallionsprs, 0, sizeof(medallionsprs));
10437 200 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10438 200 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10439
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t q = 0; q < 4; ++q)
10440 {
10441
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 800 times.
3200 for(int32_t p = 0; p < 3; ++p)
10442 {
10443 2400 drowningspr[q][p] = divespr[q][p];
10444 2400 drowning_lavaspr[q][p] = divespr[q][p];
10445 2400 }
10446 800 }
10447 200 memset(sideswimspr, 0, sizeof(sideswimspr));
10448 200 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10449 200 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10450 200 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10451 200 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10452 200 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10453 200 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10454 200 }
10455
10456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if(FFCore.quest_format[vInitData] < 34)
10457 {
10458 305 bool fastswim = zinit.hero_swim_speed > 60;
10459 // '2/3' or '1/2'
10460 305 zinit.hero_swim_mult = fastswim ? 2 : 1;
10461 305 zinit.hero_swim_div = fastswim ? 3 : 2;
10462 305 }
10463 305 return 0;
10464 305 }
10465
10466 33660 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10467 {
10468 33660 arr[spr_tile] = tile;
10469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33660 times.
33660 arr[spr_flip] = (flip > 3 ? 0 : flip);
10470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33660 times.
33660 arr[spr_extend] = (ext > 2 ? 0 : ext);
10471 33660 }
10472 //Used to read the player sprites as int32_t, not word.
10473 198 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10474 {
10475 198 zinit.hero_swim_speed=67; //default
10476 198 setupherotiles(zinit.heroAnimationStyle);
10477 198 setupherodefenses();
10478 198 setupherooffsets();
10479
10480 int32_t tile, tile2;
10481 byte flip, extend, dummy_byte;
10482
10483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>=0)
10484 {
10485
10486
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10487 {
10488
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10489 {
10490 return qe_invalid;
10491 }
10492
10493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10494 {
10495 return qe_invalid;
10496 }
10497
10498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10499 {
10500 return qe_invalid;
10501 }
10502
10503 792 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10504 792 }
10505
10506
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10507 {
10508
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10509 {
10510 return qe_invalid;
10511 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10514 {
10515 return qe_invalid;
10516 }
10517
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10519 {
10520 return qe_invalid;
10521 }
10522
10523 792 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10524 792 }
10525
10526
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10527 {
10528
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10529 {
10530 return qe_invalid;
10531 }
10532
10533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10534 {
10535 return qe_invalid;
10536 }
10537
10538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10539 {
10540 return qe_invalid;
10541 }
10542
10543 792 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10544 792 }
10545
10546
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10547 {
10548
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10549 {
10550 return qe_invalid;
10551 }
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10554 {
10555 return qe_invalid;
10556 }
10557
10558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10559 {
10560 return qe_invalid;
10561 }
10562
10563 792 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10564 792 }
10565
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>1)
10567 {
10568
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10569 {
10570
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10571 {
10572 return qe_invalid;
10573 }
10574
10575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10576 {
10577 return qe_invalid;
10578 }
10579
10580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10581 {
10582 return qe_invalid;
10583 }
10584
10585 792 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10586 792 }
10587 198 }
10588
10589
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10590 {
10591
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10592 {
10593 return qe_invalid;
10594 }
10595
10596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10597 {
10598 return qe_invalid;
10599 }
10600
10601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10602 {
10603 return qe_invalid;
10604 }
10605
10606 792 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10607 792 }
10608
10609
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10610 {
10611
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10612 {
10613 return qe_invalid;
10614 }
10615
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10617 {
10618 return qe_invalid;
10619 }
10620
10621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10622 {
10623 return qe_invalid;
10624 }
10625
10626 792 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10627 792 }
10628
10629
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&tile,f))
10630 {
10631 return qe_invalid;
10632 }
10633
10634 198 flip=0;
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>0)
10637 {
10638
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&flip,f))
10639 {
10640 return qe_invalid;
10641 }
10642 198 }
10643
10644
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&extend,f))
10645 {
10646 return qe_invalid;
10647 }
10648
10649 198 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10650
10651
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(v_herosprites>0)
10652 {
10653 198 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10654
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 198 times.
594 for(int32_t i=0; i<2; i++)
10655 {
10656
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 396 times.
1584 for(int32_t j=0; j<num_holdsprs; j++)
10657 {
10658
1/2
✓ Branch 0 taken 1188 times.
✗ Branch 1 not taken.
1188 if(!p_igetl(&tile,f))
10659 {
10660 return qe_invalid;
10661 }
10662
10663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1188 times.
1188 if(!p_getc(&flip,f))
10664 {
10665 return qe_invalid;
10666 }
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1188 times.
1188 if(!p_getc(&extend,f))
10669 {
10670 return qe_invalid;
10671 }
10672
10673 1188 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10674 1188 }
10675 396 }
10676 198 }
10677 else
10678 {
10679 for(int32_t i=0; i<2; i++)
10680 {
10681 if(!p_igetl(&tile,f))
10682 {
10683 return qe_invalid;
10684 }
10685
10686 if(!p_igetl(&tile2,f))
10687 {
10688 return qe_invalid;
10689 }
10690
10691 if(!p_getc(&extend,f))
10692 {
10693 return qe_invalid;
10694 }
10695
10696 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10697 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10698 }
10699 }
10700
10701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>2)
10702 {
10703
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10704 {
10705
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10706 {
10707 return qe_invalid;
10708 }
10709
10710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10711 {
10712 return qe_invalid;
10713 }
10714
10715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10716 {
10717 return qe_invalid;
10718 }
10719
10720 792 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10721 792 }
10722 198 }
10723
10724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>3)
10725 {
10726
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10727 {
10728
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10729 {
10730 return qe_invalid;
10731 }
10732
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10734 {
10735 return qe_invalid;
10736 }
10737
10738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10739 {
10740 return qe_invalid;
10741 }
10742
10743 792 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10744 792 }
10745 198 }
10746
10747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>4)
10748 {
10749
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&dummy_byte,f))
10750 {
10751 return qe_invalid;
10752 }
10753
10754 198 zinit.hero_swim_speed=(byte)dummy_byte;
10755 198 }
10756
10757
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(v_herosprites>6)
10758 {
10759
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10760 {
10761
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10762 return qe_invalid;
10763
10764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10765 return qe_invalid;
10766
10767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10768 return qe_invalid;
10769
10770 792 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10771 792 }
10772
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10773 {
10774
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10775 return qe_invalid;
10776
10777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10778 return qe_invalid;
10779
10780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10781 return qe_invalid;
10782
10783 792 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10784 792 }
10785
10786
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10787 {
10788
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10789 return qe_invalid;
10790
10791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10792 return qe_invalid;
10793
10794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10795 return qe_invalid;
10796
10797 792 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10798 792 }
10799
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10800 {
10801
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10802 return qe_invalid;
10803
10804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10805 return qe_invalid;
10806
10807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10808 return qe_invalid;
10809
10810 792 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10811 792 }
10812
10813
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10814 {
10815
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10816 return qe_invalid;
10817
10818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10819 return qe_invalid;
10820
10821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10822 return qe_invalid;
10823
10824 792 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10825 792 }
10826
10827
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10828 {
10829
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10830 return qe_invalid;
10831
10832
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10833 return qe_invalid;
10834
10835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10836 return qe_invalid;
10837
10838 792 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10839 792 }
10840
10841
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10842 {
10843
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10844 return qe_invalid;
10845
10846
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10850 return qe_invalid;
10851
10852 792 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10853 792 }
10854
10855
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10856 {
10857
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10858 return qe_invalid;
10859
10860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10861 return qe_invalid;
10862
10863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10864 return qe_invalid;
10865
10866 792 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10867 792 }
10868
10869
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10870 {
10871
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10872 return qe_invalid;
10873
10874
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10878 return qe_invalid;
10879
10880 792 byte frames = 0;
10881
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 772 times.
792 if(v_herosprites > 15)
10882 {
10883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 772 times.
772 if(!p_getc(&frames,f))
10884 return qe_invalid;
10885 772 }
10886
10887 792 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10888 792 liftingspr[q][spr_frames] = frames;
10889 792 }
10890
10891
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10892 {
10893
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10894 return qe_invalid;
10895
10896
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10897 return qe_invalid;
10898
10899
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10900 return qe_invalid;
10901
10902 792 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10903 792 }
10904
10905
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10906 {
10907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&tile,f))
10908 return qe_invalid;
10909
10910
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10911 return qe_invalid;
10912
10913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10914 return qe_invalid;
10915
10916 792 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10917 792 }
10918
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10919 {
10920
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10921 return qe_invalid;
10922
10923
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10924 return qe_invalid;
10925
10926
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10927 return qe_invalid;
10928
10929 792 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10930 792 }
10931
10932
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10933 {
10934
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10935 return qe_invalid;
10936
10937
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10938 return qe_invalid;
10939
10940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10941 return qe_invalid;
10942
10943 792 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10944 792 }
10945
10946
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10947 {
10948
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10949 return qe_invalid;
10950
10951
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10952 return qe_invalid;
10953
10954
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10955 return qe_invalid;
10956
10957 792 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10958 792 }
10959
10960
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10961 {
10962
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10963 return qe_invalid;
10964
10965
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10966 return qe_invalid;
10967
10968
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10969 return qe_invalid;
10970
10971 792 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10972 792 }
10973
10974
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10975 {
10976
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10977 return qe_invalid;
10978
10979
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10980 return qe_invalid;
10981
10982
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10983 return qe_invalid;
10984
10985 792 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10986 792 }
10987
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10988 {
10989
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10990 return qe_invalid;
10991
10992
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10993 return qe_invalid;
10994
10995
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10996 return qe_invalid;
10997
10998 792 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10999 792 }
11000
11001
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11002 {
11003
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11004 return qe_invalid;
11005
11006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11007 return qe_invalid;
11008
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11010 return qe_invalid;
11011
11012 792 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11013 792 }
11014
11015
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11016 {
11017
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11018 return qe_invalid;
11019
11020
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11021 return qe_invalid;
11022
11023
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11024 return qe_invalid;
11025
11026 792 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11027 792 }
11028
11029
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11030 {
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&tile,f))
11032 return qe_invalid;
11033
11034
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11035 return qe_invalid;
11036
11037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11038 return qe_invalid;
11039
11040 792 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11041 792 }
11042
11043
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11044 {
11045
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11046 return qe_invalid;
11047
11048
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11049 return qe_invalid;
11050
11051
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11052 return qe_invalid;
11053
11054 792 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11055 792 }
11056
11057
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11058 {
11059
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11060 return qe_invalid;
11061
11062
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11063 return qe_invalid;
11064
11065
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11066 return qe_invalid;
11067
11068 792 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11069 792 }
11070
11071
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11072 {
11073
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11074 return qe_invalid;
11075
11076
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11077 return qe_invalid;
11078
11079
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11080 return qe_invalid;
11081
11082 792 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11083 792 }
11084
11085
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 198 times.
792 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11086 {
11087
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetl(&tile,f))
11088 return qe_invalid;
11089
11090
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_getc(&flip,f))
11091 return qe_invalid;
11092
11093
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_getc(&extend,f))
11094 return qe_invalid;
11095
11096 594 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11097 594 }
11098 198 }
11099 else
11100 {
11101 memset(frozenspr, 0, sizeof(frozenspr));
11102 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11103 memset(onfirespr, 0, sizeof(onfirespr));
11104 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11105 memset(diggingspr, 0, sizeof(diggingspr));
11106 memset(usingrodspr, 0, sizeof(usingrodspr));
11107 memset(usingcanespr, 0, sizeof(usingcanespr));
11108 memset(pushingspr, 0, sizeof(pushingspr));
11109 memset(liftingspr, 0, sizeof(liftingspr));
11110 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11111 memset(stunnedspr, 0, sizeof(stunnedspr));
11112 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11113 memset(fallingspr, 0, sizeof(fallingspr));
11114 memset(shockedspr, 0, sizeof(shockedspr));
11115 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11116 memset(pullswordspr, 0, sizeof(pullswordspr));
11117 memset(readingspr, 0, sizeof(readingspr));
11118 memset(slash180spr, 0, sizeof(slash180spr));
11119 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11120 memset(dashspr, 0, sizeof(dashspr));
11121 memset(bonkspr, 0, sizeof(bonkspr));
11122 memset(medallionsprs, 0, sizeof(medallionsprs));
11123 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11124 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11125 for(int32_t q = 0; q < 4; ++q)
11126 {
11127 for(int32_t p = 0; p < 3; ++p)
11128 {
11129 drowningspr[q][p] = divespr[q][p];
11130 drowning_lavaspr[q][p] = divespr[q][p];
11131 }
11132 }
11133 }
11134
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 8)
11135 {
11136
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11137 {
11138
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11139 return qe_invalid;
11140
11141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11142 return qe_invalid;
11143
11144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11145 return qe_invalid;
11146
11147 792 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11148 792 }
11149 198 }
11150 else
11151 {
11152 memset(sideswimspr, 0, sizeof(sideswimspr));
11153 }
11154
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 9)
11155 {
11156
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11157 {
11158
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11159 return qe_invalid;
11160
11161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11162 return qe_invalid;
11163
11164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11165 return qe_invalid;
11166
11167 792 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11168 792 }
11169
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11170 {
11171
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11172 return qe_invalid;
11173
11174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11175 return qe_invalid;
11176
11177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11178 return qe_invalid;
11179
11180 792 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11181 792 }
11182
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11183 {
11184
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11185 return qe_invalid;
11186
11187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11188 return qe_invalid;
11189
11190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11191 return qe_invalid;
11192
11193 792 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11194 792 }
11195
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11196 {
11197
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11198 return qe_invalid;
11199
11200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11201 return qe_invalid;
11202
11203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11204 return qe_invalid;
11205
11206 792 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11207 792 }
11208 198 }
11209 else
11210 {
11211 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11212 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11213 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11214 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11215 }
11216
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 10)
11217 {
11218
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11219 {
11220 int32_t hmr;
11221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&hmr,f))
11222 return qe_invalid;
11223
11224 792 hammeroffsets[q] = hmr;
11225 792 }
11226 198 }
11227 else
11228 {
11229 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11230 }
11231
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 11)
11232 {
11233
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 198 times.
792 for(int32_t q = 0; q < 3; ++q)
11234 {
11235
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetl(&tile,f))
11236 return qe_invalid;
11237
11238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
594 if(!p_getc(&flip,f))
11239 return qe_invalid;
11240
11241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
594 if(!p_getc(&extend,f))
11242 return qe_invalid;
11243
11244 594 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11245 594 }
11246 198 }
11247 else
11248 {
11249 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11250 }
11251
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 12)
11252 {
11253
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&tile,f))
11254 return qe_invalid;
11255
11256
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&flip,f))
11257 return qe_invalid;
11258
11259
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&extend,f))
11260 return qe_invalid;
11261 198 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11262
11263 198 }
11264 else
11265 {
11266 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11267 }
11268
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 13)
11269 {
11270
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11271 {
11272
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11273 return qe_invalid;
11274
11275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11276 return qe_invalid;
11277
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11279 return qe_invalid;
11280
11281 792 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11282 792 }
11283 198 }
11284 else
11285 {
11286 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11287 }
11288
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 14)
11289 {
11290
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11291 {
11292
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11293 return qe_invalid;
11294
11295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11296 return qe_invalid;
11297
11298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11299 return qe_invalid;
11300
11301 792 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11302 792 }
11303 198 }
11304 else
11305 {
11306 memset(revslashspr, 0, sizeof(revslashspr));
11307 }
11308
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 7)
11309 {
11310 198 int32_t num_defense = wMax;
11311 198 byte def = 0;
11312
11313 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11314 /*if(v_herosprites > [x])
11315 * {
11316 * num_defense = 146 //value of wMax on version 8
11317 * }
11318 */
11319
11320
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 198 times.
29106 for (int32_t q = 0; q < num_defense; q++)
11321 {
11322
1/2
✓ Branch 0 taken 28908 times.
✗ Branch 1 not taken.
28908 if (!p_getc(&def, f))
11323 return qe_invalid;
11324
11325 28908 hero_defenses[q] = def;
11326 28908 }
11327 198 }
11328 else
11329 {
11330 int32_t num_defense = wMax;
11331 for (int32_t q = 0; q < num_defense; q++)
11332 {
11333 hero_defenses[q] = 0;
11334 }
11335 }
11336 198 }
11337
11338
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 11 times.
198 if(FFCore.quest_format[vInitData] < 34)
11339 {
11340 11 bool fastswim = zinit.hero_swim_speed > 60;
11341 // '2/3' or '1/2'
11342 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11343 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11344 11 }
11345 198 return 0;
11346 198 }
11347
11348
11349 398 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11350 {
11351 //these are here to bypass compiler warnings about unused arguments
11352 398 Header=Header;
11353
11354 dword dummy;
11355 398 word s_version=0;
11356
11357 //section version info
11358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
11359 {
11360 return qe_invalid;
11361 }
11362
11363 398 FFCore.quest_format[vHeroSprites] = s_version;
11364
11365
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
11366 {
11367 return qe_invalid;
11368 }
11369
11370 //section size
11371
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
11372 {
11373 return qe_invalid;
11374 }
11375
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if ( s_version >= 6 )
11376 {
11377 198 return readherosprites3(f, s_version);
11378 }
11379 200 else return readherosprites2(f, s_version);
11380 398 }
11381
11382 217 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11383 {
11384 217 subscreens_active.clear();
11385 217 subscreens_passive.clear();
11386 217 subscreens_overlay.clear();
11387
2/2
✓ Branch 0 taken 27776 times.
✓ Branch 1 taken 217 times.
27993 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11388 {
11389 subscreen_group g;
11390 27776 memset(&g,0,sizeof(subscreen_group));
11391 27776 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(ret!=0)
11393 return ret;
11394
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 26659 times.
27776 if(g.objects[0].type == ssoNULL) continue;
11395
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 650 times.
1117 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11396 1117 ZCSubscreen& sub = vec.emplace_back();
11397 1117 sub.load_old(g);
11398 1117 }
11399
11400 217 return 0;
11401 217 }
11402
11403 27776 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11404 {
11405 27776 int32_t numsub=0;
11406 27776 byte temp_ss=0;
11407 subscreen_object temp_sub_stack;
11408 27776 subscreen_object *temp_sub = &temp_sub_stack;
11409
11410 char tempname[64];
11411
11412 // FWIW I never saw anything bigger than 20.
11413 #define MAX_DP1_LEN 1024
11414 char tempdp1[MAX_DP1_LEN];
11415
11416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(!pfread(tempname,64,f))
11417 {
11418 return qe_invalid;
11419 }
11420
11421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version > 1)
11422 {
11423
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_getc(&temp_ss,f))
11424 {
11425 return qe_invalid;
11426 }
11427 27776 }
11428
11429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version < 4)
11430 {
11431 uint8_t tmp=0;
11432
11433 if(!p_getc(&tmp,f))
11434 {
11435 return qe_invalid;
11436 }
11437
11438 numsub = (int32_t)tmp;
11439 }
11440 else
11441 {
11442 word tmp;
11443
11444
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_igetw(&tmp, f))
11445 {
11446 return qe_invalid;
11447 }
11448
11449 27776 numsub = (int32_t)tmp;
11450 }
11451
11452 int32_t j;
11453
11454
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71950 times.
✓ Branch 2 taken 44174 times.
✓ Branch 3 taken 27776 times.
71950 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11455 {
11456 44174 memset(temp_sub,0,sizeof(subscreen_object));
11457
11458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 switch(g->objects[j].type)
11459 {
11460 case ssoTEXT:
11461 case ssoTEXTBOX:
11462 case ssoCURRENTITEMTEXT:
11463 case ssoCURRENTITEMCLASSTEXT:
11464 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11465
11466 //fall through
11467 default:
11468 44174 memset(&g->objects[j],0,sizeof(subscreen_object));
11469 44174 break;
11470 }
11471
11472
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->type),f))
11473 return qe_invalid;
11474
11475
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->pos),f))
11476 return qe_invalid;
11477
11478
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(s_version < 5)
11479 {
11480 switch(temp_sub->pos)
11481 {
11482 case 0:
11483 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11484 break;
11485
11486 case 1:
11487 temp_sub->pos = sspUP;
11488 break;
11489
11490 case 2:
11491 temp_sub->pos = sspDOWN;
11492 break;
11493
11494 default:
11495 temp_sub->pos = 0;
11496 }
11497 }
11498
11499
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->x),f))
11500 return qe_invalid;
11501
11502
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->y),f))
11503 return qe_invalid;
11504
11505
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->w),f))
11506 return qe_invalid;
11507
11508
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->h),f))
11509 return qe_invalid;
11510
11511
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype1),f))
11512 return qe_invalid;
11513
11514
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color1),f))
11515 return qe_invalid;
11516
11517
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype2),f))
11518 return qe_invalid;
11519
11520
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color2),f))
11521 return qe_invalid;
11522
11523
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype3),f))
11524 return qe_invalid;
11525
11526
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color3),f))
11527 return qe_invalid;
11528
11529
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d1),f))
11530 return qe_invalid;
11531
11532
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d2),f))
11533 return qe_invalid;
11534
11535
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d3),f))
11536 return qe_invalid;
11537
11538
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d4),f))
11539 return qe_invalid;
11540
11541
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d5),f))
11542 return qe_invalid;
11543
11544
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d6),f))
11545 return qe_invalid;
11546
11547
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d7),f))
11548 return qe_invalid;
11549
11550
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d8),f))
11551 return qe_invalid;
11552
11553
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d9),f))
11554 return qe_invalid;
11555
11556
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d10),f))
11557 return qe_invalid;
11558
11559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 if(s_version < 2)
11560 {
11561 if(!p_igetl(&(temp_sub->speed),f))
11562 return qe_invalid;
11563
11564 if(!p_igetl(&(temp_sub->delay),f))
11565 return qe_invalid;
11566
11567 if(!p_igetl(&(temp_sub->frame),f))
11568 return qe_invalid;
11569 }
11570 else
11571 {
11572
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->speed),f))
11573 return qe_invalid;
11574
11575
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->delay),f))
11576 return qe_invalid;
11577
11578
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->frame),f))
11579 return qe_invalid;
11580 }
11581
11582 44174 int32_t temp_size=0;
11583
11584 // bool deletets = false;
11585
4/4
✓ Branch 0 taken 19541 times.
✓ Branch 1 taken 3389 times.
✓ Branch 2 taken 21002 times.
✓ Branch 3 taken 242 times.
44174 switch(temp_sub->type)
11586 {
11587 case ssoTEXT:
11588 case ssoTEXTBOX:
11589 case ssoCURRENTITEMTEXT:
11590 case ssoCURRENTITEMCLASSTEXT:
11591 {
11592 word temptempsize;
11593
11594
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!p_igetw(&temptempsize,f))
11595 {
11596 return qe_invalid;
11597 }
11598
11599 //temptempsize = temp1 + (temp2 << 8);
11600 3389 temp_size = (int32_t)temptempsize;
11601 3389 uint32_t char_length = temp_size+2;
11602
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if (char_length > MAX_DP1_LEN)
11603 {
11604 return qe_invalid;
11605 }
11606 3389 tempdp1[char_length - 1] = '\0';
11607
11608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
3389 if(temp_size)
11609
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!pfread(tempdp1,temp_size+1,f))
11610 return qe_invalid;
11611 3389 break;
11612 }
11613
11614 case ssoLIFEMETER:
11615
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11616 temp_sub->d3 = 1;
11617
11618
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(!p_getc(&(temp_sub->dp1),f))
11619 return qe_invalid;
11620
11621 242 break;
11622
11623
11624 case ssoCURRENTITEM:
11625
11626
1/2
✓ Branch 0 taken 19541 times.
✗ Branch 1 not taken.
19541 if(s_version < 6)
11627 {
11628 switch(temp_sub->d1)
11629 {
11630 case ssiBOMB:
11631 temp_sub->d1 = itype_bomb;
11632 break;
11633
11634 case ssiSWORD:
11635 temp_sub->d1 = itype_sword;
11636 break;
11637
11638 case ssiSHIELD:
11639 temp_sub->d1 = itype_shield;
11640 break;
11641
11642 case ssiCANDLE:
11643 temp_sub->d1 = itype_candle;
11644 break;
11645
11646 case ssiLETTER:
11647 temp_sub->d1 = itype_letter;
11648 break;
11649
11650 case ssiPOTION:
11651 temp_sub->d1 = itype_potion;
11652 break;
11653
11654 case ssiLETTERPOTION:
11655 temp_sub->d1 = itype_letterpotion;
11656 break;
11657
11658 case ssiBOW:
11659 temp_sub->d1 = itype_bow;
11660 break;
11661
11662 case ssiARROW:
11663 temp_sub->d1 = itype_arrow;
11664 break;
11665
11666 case ssiBOWANDARROW:
11667 temp_sub->d1 = itype_bowandarrow;
11668 break;
11669
11670 case ssiBAIT:
11671 temp_sub->d1 = itype_bait;
11672 break;
11673
11674 case ssiRING:
11675 temp_sub->d1 = itype_ring;
11676 break;
11677
11678 case ssiBRACELET:
11679 temp_sub->d1 = itype_bracelet;
11680 break;
11681
11682 case ssiMAP:
11683 temp_sub->d1 = itype_map;
11684 break;
11685
11686 case ssiCOMPASS:
11687 temp_sub->d1 = itype_compass;
11688 break;
11689
11690 case ssiBOSSKEY:
11691 temp_sub->d1 = itype_bosskey;
11692 break;
11693
11694 case ssiMAGICKEY:
11695 temp_sub->d1 = itype_magickey;
11696 break;
11697
11698 case ssiBRANG:
11699 temp_sub->d1 = itype_brang;
11700 break;
11701
11702 case ssiWAND:
11703 temp_sub->d1 = itype_wand;
11704 break;
11705
11706 case ssiRAFT:
11707 temp_sub->d1 = itype_raft;
11708 break;
11709
11710 case ssiLADDER:
11711 temp_sub->d1 = itype_ladder;
11712 break;
11713
11714 case ssiWHISTLE:
11715 temp_sub->d1 = itype_whistle;
11716 break;
11717
11718 case ssiBOOK:
11719 temp_sub->d1 = itype_book;
11720 break;
11721
11722 case ssiWALLET:
11723 temp_sub->d1 = itype_wallet;
11724 break;
11725
11726 case ssiSBOMB:
11727 temp_sub->d1 = itype_sbomb;
11728 break;
11729
11730 case ssiHCPIECE:
11731 temp_sub->d1 = itype_heartpiece;
11732 break;
11733
11734 case ssiAMULET:
11735 temp_sub->d1 = itype_amulet;
11736 break;
11737
11738 case ssiFLIPPERS:
11739 temp_sub->d1 = itype_flippers;
11740 break;
11741
11742 case ssiHOOKSHOT:
11743 temp_sub->d1 = itype_hookshot;
11744 break;
11745
11746 case ssiLENS:
11747 temp_sub->d1 = itype_lens;
11748 break;
11749
11750 case ssiHAMMER:
11751 temp_sub->d1 = itype_hammer;
11752 break;
11753
11754 case ssiBOOTS:
11755 temp_sub->d1 = itype_boots;
11756 break;
11757
11758 case ssiDIVINEFIRE:
11759 temp_sub->d1 = itype_divinefire;
11760 break;
11761
11762 case ssiDIVINEESCAPE:
11763 temp_sub->d1 = itype_divineescape;
11764 break;
11765
11766 case ssiDIVINEPROTECTION:
11767 temp_sub->d1 = itype_divineprotection;
11768 break;
11769
11770 case ssiQUIVER:
11771 temp_sub->d1 = itype_quiver;
11772 break;
11773
11774 case ssiBOMBBAG:
11775 temp_sub->d1 = itype_bombbag;
11776 break;
11777
11778 case ssiCBYRNA:
11779 temp_sub->d1 = itype_cbyrna;
11780 break;
11781
11782 case ssiROCS:
11783 temp_sub->d1 = itype_rocs;
11784 break;
11785
11786 case ssiHOVERBOOTS:
11787 temp_sub->d1 = itype_hoverboots;
11788 break;
11789
11790 case ssiSPINSCROLL:
11791 temp_sub->d1 = itype_spinscroll;
11792 break;
11793
11794 case ssiCROSSSCROLL:
11795 temp_sub->d1 = itype_crossscroll;
11796 break;
11797
11798 case ssiQUAKESCROLL:
11799 temp_sub->d1 = itype_quakescroll;
11800 break;
11801
11802 case ssiWHISPRING:
11803 temp_sub->d1 = itype_whispring;
11804 break;
11805
11806 case ssiCHARGERING:
11807 temp_sub->d1 = itype_chargering;
11808 break;
11809
11810 case ssiPERILSCROLL:
11811 temp_sub->d1 = itype_perilscroll;
11812 break;
11813
11814 case ssiWEALTHMEDAL:
11815 temp_sub->d1 = itype_wealthmedal;
11816 break;
11817
11818 case ssiHEARTRING:
11819 temp_sub->d1 = itype_heartring;
11820 break;
11821
11822 case ssiMAGICRING:
11823 temp_sub->d1 = itype_magicring;
11824 break;
11825
11826 case ssiSPINSCROLL2:
11827 temp_sub->d1 = itype_spinscroll2;
11828 break;
11829
11830 case ssiQUAKESCROLL2:
11831 temp_sub->d1 = itype_quakescroll2;
11832 break;
11833
11834 case ssiAGONY:
11835 temp_sub->d1 = itype_agony;
11836 break;
11837
11838 case ssiSTOMPBOOTS:
11839 temp_sub->d1 = itype_stompboots;
11840 break;
11841
11842 case ssiWHIMSICALRING:
11843 temp_sub->d1 = itype_whimsicalring;
11844 break;
11845
11846 case ssiPERILRING:
11847 temp_sub->d1 = itype_perilring;
11848 break;
11849
11850 default:
11851 temp_sub->d1 += itype_custom1 - ssiMAX;
11852 }
11853 }
11854
11855 //fall-through
11856 default:
11857
1/2
✓ Branch 0 taken 40543 times.
✗ Branch 1 not taken.
40543 if(!p_getc(&(temp_sub->dp1),f))
11858 return qe_invalid;
11859
11860 40543 break;
11861 }
11862
11863
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 35480 times.
44174 if(s_version < 7)
11864 {
11865
3/3
✓ Branch 0 taken 29642 times.
✓ Branch 1 taken 1270 times.
✓ Branch 2 taken 4568 times.
35480 switch(temp_sub->type)
11866 {
11867 case ssoMAGICGAUGE:
11868 {
11869
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1136 times.
1270 if(!temp_sub->d9)
11870 1136 temp_sub->d9 = -1; //-1 now represents 'always'
11871 1270 break;
11872 }
11873 case ssoLIFEGAUGE:
11874 4568 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11875 4568 break;
11876 }
11877 35480 }
11878
11879
3/3
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 39307 times.
✓ Branch 2 taken 1478 times.
44174 switch(temp_sub->type)
11880 {
11881 case ssoTEXT:
11882 case ssoTEXTBOX:
11883 case ssoCURRENTITEMTEXT:
11884 case ssoCURRENTITEMCLASSTEXT:
11885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3389 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11886
11887 3389 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11888 3389 g->objects[j].dp1 = new char[temp_size+2];
11889 3389 strcpy((char*)g->objects[j].dp1,tempdp1);
11890 3389 break;
11891
11892 case ssoCOUNTER:
11893
1/2
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
1478 if(s_version<3)
11894 {
11895 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11896 temp_sub->d8=0;
11897 }
11898
11899 default:
11900 40785 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11901 40785 break;
11902 }
11903
11904 44174 g->name[0] = '\0';
11905 44174 strncat(g->name, tempname, 64 - 1);
11906 44174 g->ss_type = temp_ss;
11907 44174 }
11908
11909
2/2
✓ Branch 0 taken 7066482 times.
✓ Branch 1 taken 27776 times.
7094258 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11910 {
11911 //clear all unused object in this subscreen -DD
11912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7066482 times.
7066482 switch(g->objects[j].type)
11913 {
11914 case ssoTEXT:
11915 case ssoTEXTBOX:
11916 case ssoCURRENTITEMTEXT:
11917 case ssoCURRENTITEMCLASSTEXT:
11918 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11919
11920 //fall through
11921 default:
11922 7066482 memset(&g->objects[j],0,sizeof(subscreen_object));
11923 7066482 break;
11924 }
11925 7066482 }
11926
11927 27776 return 0;
11928 27776 }
11929
11930 398 int32_t readsubscreens(PACKFILE *f)
11931 {
11932 word s_version;
11933 dword dummy;
11934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
11935 return qe_invalid;
11936 398 FFCore.quest_format[vSubscreen] = s_version;
11937
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
11938 return qe_invalid;
11939
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f)) //section size
11940 return qe_invalid;
11941
11942
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version < 8)
11943 217 return read_old_subscreens(f,s_version);
11944
11945 181 subscreens_active.clear();
11946 181 subscreens_passive.clear();
11947 181 subscreens_overlay.clear();
11948
11949 byte sz;
11950
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_getc(&sz,f))
11951 return qe_invalid;
11952
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 181 times.
770 for(byte q = 0; q < sz; ++q)
11953 {
11954 589 ZCSubscreen& tmp = subscreens_active.emplace_back();
11955
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if (auto ret = tmp.read(f, s_version))
11956 return ret;
11957 589 }
11958
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_getc(&sz,f))
11959 return qe_invalid;
11960
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 181 times.
873 for(byte q = 0; q < sz; ++q)
11961 {
11962 692 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11963
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if (auto ret = tmp.read(f, s_version))
11964 return ret;
11965 692 }
11966
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_getc(&sz,f))
11967 return qe_invalid;
11968
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 181 times.
191 for(byte q = 0; q < sz; ++q)
11969 {
11970 10 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (auto ret = tmp.read(f, s_version))
11972 return ret;
11973 10 }
11974 181 return 0;
11975 398 }
11976
11977 void reset_subscreen(subscreen_group *tempss)
11978 {
11979 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11980 {
11981 switch(tempss->objects[i].type)
11982 {
11983 case ssoTEXT:
11984 case ssoTEXTBOX:
11985 case ssoCURRENTITEMTEXT:
11986 case ssoCURRENTITEMCLASSTEXT:
11987 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11988
11989 //fall through
11990 default:
11991 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11992 break;
11993 }
11994 }
11995 }
11996
11997 117 void reset_subscreens()
11998 {
11999 117 subscreens_active.clear();
12000 117 subscreens_passive.clear();
12001 117 subscreens_overlay.clear();
12002 117 }
12003
12004 117 int32_t setupsubscreens()
12005 {
12006 117 reset_subscreens();
12007 //return 0;
12008
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 234 times.
351 for(int q = 0; q < 2; ++q)
12009 {
12010 234 subscreens_active.emplace_back();
12011 234 subscreens_passive.emplace_back();
12012 234 }
12013 117 int32_t tempsubscreen=subscr_mode;
12014
12015
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(tempsubscreen>=ssdtMAX)
12016 tempsubscreen=0;
12017
12018
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 switch(tempsubscreen)
12019 {
12020 case ssdtOLD:
12021 case ssdtNEWSUBSCR:
12022 case ssdtREV2:
12023 case ssdtBSZELDA:
12024 case ssdtBSZELDAMODIFIED:
12025 case ssdtBSZELDAENHANCED:
12026 case ssdtBSZELDACOMPLETE:
12027 {
12028 117 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
12029 117 subscreens_active[0].sub_type=sstACTIVE;
12030 117 subscreens_active[0].name = "Active Subscreen (Triforce)";
12031 117 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
12032 117 subscreens_active[1].sub_type=sstACTIVE;
12033 117 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
12034 117 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
12035 117 subscreens_passive[0].sub_type=sstPASSIVE;
12036 117 subscreens_passive[0].name = "Passive Subscreen (Magic)";
12037 117 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
12038 117 subscreens_passive[1].sub_type=sstPASSIVE;
12039 117 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
12040 117 break;
12041 }
12042
12043 case ssdtZ3:
12044 {
12045 subscreens_active[0].load_old(z3_active_a);
12046 subscreens_active[0].sub_type=sstACTIVE;
12047 subscreens_active[1].load_old(z3_active_ab);
12048 subscreens_active[1].sub_type=sstACTIVE;
12049 subscreens_passive[0].load_old(z3_passive_a);
12050 subscreens_passive[0].sub_type=sstPASSIVE;
12051 subscreens_passive[1].load_old(z3_passive_ab);
12052 subscreens_passive[1].sub_type=sstPASSIVE;
12053 break;
12054 }
12055 }
12056 117 subscr_mode = ssdtMAX;
12057 117 return 0;
12058 }
12059
12060 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
12061
12062 extern script_data *ffscripts[NUMSCRIPTFFC];
12063 extern script_data *itemscripts[NUMSCRIPTITEM];
12064 extern script_data *guyscripts[NUMSCRIPTGUYS];
12065 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12066 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12067 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12068 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12069 extern script_data *playerscripts[NUMSCRIPTHERO];
12070 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12071 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12072 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12073 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12074 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
12075
12076 static std::vector<const script_data*> read_scripts;
12077
12078 429 static script_data fake_script_data(ScriptType::None, 0);
12079
12080 528 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12081 {
12082 int32_t dummy;
12083 528 word s_version=0, zmeta_version=0;
12084 528 byte numscripts=0;
12085 528 numscripts=numscripts; //to avoid unused variables warnings
12086 int32_t ret;
12087 528 read_scripts.clear();
12088 528 zasm_scripts.clear();
12089
12090 //section version info
12091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if(!p_igetw(&s_version,f))
12092 {
12093 return qe_invalid;
12094 }
12095
12096 528 FFCore.quest_format[vFFScript] = s_version;
12097
12098
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!read_deprecated_section_cversion(f))
12099 {
12100 return qe_invalid;
12101 }
12102
12103
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 198 times.
528 if(s_version >= 18)
12104 {
12105
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&zmeta_version,f))
12106 {
12107 return qe_invalid;
12108 }
12109 198 }
12110
12111 //section size
12112
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetl(&dummy,f))
12113 {
12114 return qe_invalid;
12115 }
12116
12117
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 219 times.
528 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12118 528 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12119
12120
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 132 times.
528 if(s_version >= 27)
12121 {
12122 132 ret = read_quest_zasm(f, s_version);
12123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(ret)
12124 return qe_invalid;
12125 132 }
12126
12127 //finally... section data
12128
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 466 times.
204242 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12129 {
12130 203776 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12131
12132
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if (ret)
12133 {
12134 return qe_invalid;
12135 }
12136 203776 }
12137
12138 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12139 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12140 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12141 * there was a version bump a week before a change that broke stuff.
12142 */
12143
7/8
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
✓ Branch 4 taken 198 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 198 times.
✓ Branch 7 taken 198 times.
466 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12144 {
12145 664 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12146 664 }
12147
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version < 19)
12148 {
12149 200 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12150 200 }
12151
12152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 1)
12153 {
12154
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12155 {
12156 101888 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12157
12158
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12159 {
12160 return qe_invalid;
12161 }
12162 101888 }
12163
12164
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12165 {
12166 101888 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12167
12168
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12169 {
12170 return qe_invalid;
12171 }
12172 101888 }
12173
12174
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12175 {
12176 101888 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12177
12178
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12179 {
12180 return qe_invalid;
12181 }
12182 101888 }
12183
12184
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12185 {
12186 101888 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12187
12188
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12189 {
12190 return qe_invalid;
12191 }
12192 101888 }
12193
12194
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version > 16)
12195 {
12196
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 198 times.
1782 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12197 {
12198 1584 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12199
12200
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if (ret)
12201 {
12202 return qe_invalid;
12203 }
12204 1584 }
12205 198 }
12206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 else if(s_version > 13)
12207 {
12208 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12209 {
12210 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12211
12212 if (ret)
12213 {
12214 return qe_invalid;
12215 }
12216 }
12217
12218 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12219 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12220
12221 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12222 }
12223
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 else if(s_version > 4)
12224 {
12225
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12226 {
12227 800 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12228
12229
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if (ret)
12230 {
12231 return qe_invalid;
12232 }
12233 800 }
12234
12235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12236
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12237
12238
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12239
12240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12241
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12242
12243
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12244
12245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12246
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_F6];
12247
12248
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12249
12250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12251
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12252
12253
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12254 200 }
12255 else
12256 {
12257 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12258 {
12259 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12260
12261 if (ret)
12262 {
12263 return qe_invalid;
12264 }
12265 }
12266
12267 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12268 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12269
12270 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12271
12272 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12273 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12274
12275 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12276
12277 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12278 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12279
12280 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12281
12282 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12283 delete globalscripts[GLOBAL_SCRIPT_F6];
12284
12285 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12286
12287 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12288 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12289
12290 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12291 }
12292
12293
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version > 10) //expanded the number of Hero scripts to 5.
12294 {
12295
2/2
✓ Branch 0 taken 990 times.
✓ Branch 1 taken 198 times.
1188 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12296 {
12297 990 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12298
12299
1/2
✓ Branch 0 taken 990 times.
✗ Branch 1 not taken.
990 if (ret)
12300 {
12301 return qe_invalid;
12302 }
12303 990 }
12304 198 }
12305 else
12306 {
12307
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 200 times.
800 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12308 {
12309 600 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12310
12311
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
600 if (ret)
12312 {
12313 return qe_invalid;
12314 }
12315 600 }
12316
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[3] != NULL)
12317
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete playerscripts[3];
12318
12319
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12320
12321
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[4] != NULL)
12322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 delete playerscripts[4];
12323
12324
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12325 }
12326
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
398 if(s_version > 8 && s_version < 10)
12327 {
12328
12329 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12330 {
12331 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12332
12333 if (ret)
12334 {
12335 return qe_invalid;
12336 }
12337 }
12338 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12339 {
12340 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12341
12342 if (ret)
12343 {
12344 return qe_invalid;
12345 }
12346 }
12347
12348 }
12349
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >= 10)
12350 {
12351
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12352 {
12353 50688 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12354
12355
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12356 {
12357 return qe_invalid;
12358 }
12359 50688 }
12360
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12361 {
12362 50688 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12363
12364
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12365 {
12366 return qe_invalid;
12367 }
12368 50688 }
12369
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12370 {
12371 50688 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12372
12373
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12374 {
12375 return qe_invalid;
12376 }
12377 50688 }
12378
12379 198 }
12380
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >=12)
12381 {
12382
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12383 {
12384 50688 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12385
12386
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12387 {
12388 return qe_invalid;
12389 }
12390 50688 }
12391 198 }
12392
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >=15)
12393 {
12394
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 198 times.
101574 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12395 {
12396 101376 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12397
12398
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if (ret)
12399 {
12400 return qe_invalid;
12401 }
12402 101376 }
12403 198 }
12404
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >19)
12405 {
12406 198 word numgenscripts = NUMSCRIPTSGENERIC;
12407
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&numgenscripts,f))
12408 {
12409 return qe_invalid;
12410 }
12411
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 198 times.
101574 for(int32_t i = 0; i < numgenscripts; i++)
12412 {
12413 101376 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12414
12415
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if (ret)
12416 {
12417 return qe_invalid;
12418 }
12419 101376 }
12420 198 }
12421
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version >21)
12422 {
12423 181 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12424
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_igetw(&numsubscripts,f))
12425 {
12426 return qe_invalid;
12427 }
12428
2/2
✓ Branch 0 taken 46336 times.
✓ Branch 1 taken 181 times.
46517 for(int32_t i = 0; i < numsubscripts; i++)
12429 {
12430 46336 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12431
12432
1/2
✓ Branch 0 taken 46336 times.
✗ Branch 1 not taken.
46336 if (ret)
12433 {
12434 return qe_invalid;
12435 }
12436 46336 }
12437 181 }
12438 398 }
12439
12440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 2)
12441 {
12442 int32_t bufsize;
12443 398 p_igetl(&bufsize, f);
12444
2/4
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
398 if (bufsize < 0 || bufsize > 1024*1024*10)
12445 {
12446 // God help anyone storing more than 10MB of code in the script buffer.
12447 return qe_invalid;
12448 }
12449 398 char * buf = new char[bufsize+1];
12450 398 pfread(buf, bufsize, f);
12451 398 buf[bufsize]=0;
12452
12453
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 zScript = string(buf);
12454
12455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 delete[] buf;
12456 word numffcbindings;
12457 398 p_igetw(&numffcbindings, f);
12458
12459
2/2
✓ Branch 0 taken 10853 times.
✓ Branch 1 taken 398 times.
11251 for(int32_t i=0; i<numffcbindings; i++)
12460 {
12461 word id;
12462 10853 p_igetw(&id, f);
12463 10853 p_igetl(&bufsize, f);
12464
2/4
✓ Branch 0 taken 10853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10853 times.
10853 if (bufsize < 0 || bufsize > 1024)
12465 return qe_invalid;
12466 10853 buf = new char[bufsize+1];
12467 10853 pfread(buf, bufsize, f);
12468 10853 buf[bufsize]=0;
12469
12470 //fix for buggy older saved quests -DD
12471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10853 times.
10853 if(id < NUMSCRIPTFFC-1)
12472 10853 ffcmap[id].scriptname = buf;
12473
12474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10853 times.
10853 delete[] buf;
12475 10853 }
12476
12477 word numglobalbindings;
12478 398 p_igetw(&numglobalbindings, f);
12479
12480
2/2
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 398 times.
1977 for(int32_t i=0; i<numglobalbindings; i++)
12481 {
12482 word id;
12483 1579 p_igetw(&id, f);
12484 1579 p_igetl(&bufsize, f);
12485
2/4
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1579 times.
✗ Branch 3 not taken.
1579 if (bufsize < 0 || bufsize > 1024)
12486 return qe_invalid;
12487 1579 buf = new char[bufsize+1];
12488 1579 pfread(buf, bufsize, f);
12489 1579 buf[bufsize]=0;
12490
12491 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12492 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12493 // Ignore these. -DD
12494
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 1033 times.
1579 if (id < NUMSCRIPTGLOBAL)
12495 {
12496 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12497
1/2
✓ Branch 0 taken 1033 times.
✗ Branch 1 not taken.
1033 if(strcmp(buf,"~Continue") == 0)
12498 {
12499 globalmap[id].scriptname = "";
12500
12501 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12502 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12503 }
12504 else
12505 {
12506 1033 globalmap[id].scriptname = buf;
12507 }
12508 1033 }
12509
12510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1579 times.
1579 delete[] buf;
12511 1579 }
12512
12513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 3)
12514 {
12515 word numitembindings;
12516 398 p_igetw(&numitembindings, f);
12517
12518
2/2
✓ Branch 0 taken 1285 times.
✓ Branch 1 taken 398 times.
1683 for(int32_t i=0; i<numitembindings; i++)
12519 {
12520 word id;
12521 1285 p_igetw(&id, f);
12522 1285 p_igetl(&bufsize, f);
12523
2/4
✓ Branch 0 taken 1285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1285 times.
1285 if (bufsize < 0 || bufsize > 1024)
12524 return qe_invalid;
12525 1285 buf = new char[bufsize+1];
12526 1285 pfread(buf, bufsize, f);
12527 1285 buf[bufsize]=0;
12528
12529 //fix this too
12530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1285 times.
1285 if(id <NUMSCRIPTITEM-1)
12531 1285 itemmap[id].scriptname = buf;
12532
12533
1/2
✓ Branch 0 taken 1285 times.
✗ Branch 1 not taken.
1285 delete[] buf;
12534 1285 }
12535 398 }
12536 //(v9+)
12537
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version > 8)
12538 {
12539 //npc scripts
12540 word numnpcbindings;
12541 198 p_igetw(&numnpcbindings, f);
12542
12543
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 198 times.
230 for(int32_t i=0; i<numnpcbindings; i++)
12544 {
12545 word id;
12546 32 p_igetw(&id, f);
12547 32 p_igetl(&bufsize, f);
12548
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12549 return qe_invalid;
12550 32 buf = new char[bufsize+1];
12551 32 pfread(buf, bufsize, f);
12552 32 buf[bufsize]=0;
12553
12554 //fix this too
12555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12556 32 npcmap[id].scriptname = buf;
12557
12558
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 delete[] buf;
12559 32 }
12560 //lweapon
12561 word numlwpnbindings;
12562 198 p_igetw(&numlwpnbindings, f);
12563
12564
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 198 times.
535 for(int32_t i=0; i<numlwpnbindings; i++)
12565 {
12566 word id;
12567 337 p_igetw(&id, f);
12568 337 p_igetl(&bufsize, f);
12569
2/4
✓ Branch 0 taken 337 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 337 times.
337 if (bufsize < 0 || bufsize > 1024)
12570 return qe_invalid;
12571 337 buf = new char[bufsize+1];
12572 337 pfread(buf, bufsize, f);
12573 337 buf[bufsize]=0;
12574
12575 //fix this too
12576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(id <NUMSCRIPTWEAPONS-1)
12577 337 lwpnmap[id].scriptname = buf;
12578
12579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 delete[] buf;
12580 337 }
12581 //eweapon
12582 word numewpnbindings;
12583 198 p_igetw(&numewpnbindings, f);
12584
12585
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 198 times.
495 for(int32_t i=0; i<numewpnbindings; i++)
12586 {
12587 word id;
12588 297 p_igetw(&id, f);
12589 297 p_igetl(&bufsize, f);
12590
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12591 return qe_invalid;
12592 297 buf = new char[bufsize+1];
12593 297 pfread(buf, bufsize, f);
12594 297 buf[bufsize]=0;
12595
12596 //fix this too
12597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12598 297 ewpnmap[id].scriptname = buf;
12599
12600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12601 297 }
12602 //hero
12603 word numherobindings;
12604 198 p_igetw(&numherobindings, f);
12605
12606
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 198 times.
221 for(int32_t i=0; i<numherobindings; i++)
12607 {
12608 word id;
12609 23 p_igetw(&id, f);
12610 23 p_igetl(&bufsize, f);
12611
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12612 return qe_invalid;
12613 23 buf = new char[bufsize+1];
12614 23 pfread(buf, bufsize, f);
12615 23 buf[bufsize]=0;
12616
12617 //fix this too
12618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12619 23 playermap[id].scriptname = buf;
12620
12621
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12622 23 }
12623 //dmaps
12624 word numdmapbindings;
12625 198 p_igetw(&numdmapbindings, f);
12626
12627
2/2
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 198 times.
651 for(int32_t i=0; i<numdmapbindings; i++)
12628 {
12629 word id;
12630 453 p_igetw(&id, f);
12631 453 p_igetl(&bufsize, f);
12632
2/4
✓ Branch 0 taken 453 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 453 times.
453 if (bufsize < 0 || bufsize > 1024)
12633 return qe_invalid;
12634 453 buf = new char[bufsize+1];
12635 453 pfread(buf, bufsize, f);
12636 453 buf[bufsize]=0;
12637
12638 //fix this too
12639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 453 times.
453 if(id <NUMSCRIPTSDMAP-1)
12640 453 dmapmap[id].scriptname = buf;
12641
12642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 453 times.
453 delete[] buf;
12643 453 }
12644 //screen
12645 word numscreenbindings;
12646 198 p_igetw(&numscreenbindings, f);
12647
12648
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 198 times.
617 for(int32_t i=0; i<numscreenbindings; i++)
12649 {
12650 word id;
12651 419 p_igetw(&id, f);
12652 419 p_igetl(&bufsize, f);
12653
2/4
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
419 if (bufsize < 0 || bufsize > 1024)
12654 return qe_invalid;
12655 419 buf = new char[bufsize+1];
12656 419 pfread(buf, bufsize, f);
12657 419 buf[bufsize]=0;
12658
12659 //fix this too
12660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(id <NUMSCRIPTSDMAP-1)
12661 419 screenmap[id].scriptname = buf;
12662
12663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 delete[] buf;
12664 419 }
12665 198 }
12666
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version > 11)
12667 {
12668 word numspritebindings;
12669 198 p_igetw(&numspritebindings, f);
12670
12671
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 198 times.
249 for(int32_t i=0; i<numspritebindings; i++)
12672 {
12673 word id;
12674 51 p_igetw(&id, f);
12675 51 p_igetl(&bufsize, f);
12676
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
51 if (bufsize < 0 || bufsize > 1024)
12677 return qe_invalid;
12678 51 buf = new char[bufsize+1];
12679 51 pfread(buf, bufsize, f);
12680 51 buf[bufsize]=0;
12681
12682 //fix this too
12683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(id <NUMSCRIPTSDMAP-1)
12684 51 itemspritemap[id].scriptname = buf;
12685
12686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 delete[] buf;
12687 51 }
12688 198 }
12689
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >= 15)
12690 {
12691 word numcombobindings;
12692 198 p_igetw(&numcombobindings, f);
12693
12694
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 198 times.
355 for(int32_t i=0; i<numcombobindings; i++)
12695 {
12696 word id;
12697 157 p_igetw(&id, f);
12698 157 p_igetl(&bufsize, f);
12699
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
157 if (bufsize < 0 || bufsize > 1024)
12700 return qe_invalid;
12701 157 buf = new char[bufsize+1];
12702 157 pfread(buf, bufsize, f);
12703 157 buf[bufsize]=0;
12704
12705 //fix this too
12706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12707 157 comboscriptmap[id].scriptname = buf;
12708
12709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12710 157 }
12711 198 }
12712
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version > 19)
12713 {
12714 word numgenericbindings;
12715 198 p_igetw(&numgenericbindings, f);
12716
12717
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 198 times.
2446 for(int32_t i=0; i<numgenericbindings; i++)
12718 {
12719 word id;
12720 2248 p_igetw(&id, f);
12721 2248 p_igetl(&bufsize, f);
12722
2/4
✓ Branch 0 taken 2248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2248 times.
✗ Branch 3 not taken.
2248 if (bufsize < 0 || bufsize > 1024)
12723 return qe_invalid;
12724 2248 buf = new char[bufsize+1];
12725 2248 pfread(buf, bufsize, f);
12726 2248 buf[bufsize]=0;
12727
12728 //fix this too
12729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
2248 if(id <NUMSCRIPTSGENERIC-1)
12730 2248 genericmap[id].scriptname = buf;
12731
12732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
2248 delete[] buf;
12733 2248 }
12734 198 }
12735
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version > 21)
12736 {
12737 word numsubscreenbindings;
12738 181 p_igetw(&numsubscreenbindings, f);
12739
12740
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 181 times.
189 for(int32_t i=0; i<numsubscreenbindings; i++)
12741 {
12742 word id;
12743 8 p_igetw(&id, f);
12744 8 p_igetl(&bufsize, f);
12745
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (bufsize < 0 || bufsize > 1024)
12746 return qe_invalid;
12747 8 buf = new char[bufsize+1];
12748 8 pfread(buf, bufsize, f);
12749 8 buf[bufsize]=0;
12750
12751 //fix this too
12752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12753 8 subscreenmap[id].scriptname = buf;
12754
12755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12756 8 }
12757 181 }
12758 398 }
12759
12760 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12761 // This is only updated when the scripts have been recompiled.
12762 // They should all match each other.
12763 398 std::optional<word> zscript_version;
12764
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if (s_version >= 16)
12765 {
12766
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 7706 times.
7902 for (auto script : read_scripts)
12767 {
12768
2/2
✓ Branch 0 taken 7704 times.
✓ Branch 1 taken 2 times.
7706 if (script->meta.ffscript_v == 0)
12769 {
12770 // These scripts were saved in a version prior to this field being set.
12771 // See https://discord.com/channels/876899628556091432/1368485306394738718
12772 2 zscript_version = 16;
12773 2 break;
12774 }
12775
1/2
✓ Branch 0 taken 7704 times.
✗ Branch 1 not taken.
7704 if (script->meta.ffscript_v > s_version)
12776 break;
12777
12778
2/2
✓ Branch 0 taken 7526 times.
✓ Branch 1 taken 178 times.
7704 if (!zscript_version.has_value())
12779 {
12780 178 zscript_version = script->meta.ffscript_v;
12781 178 continue;
12782 }
12783
12784
1/2
✓ Branch 0 taken 7526 times.
✗ Branch 1 not taken.
7526 if (zscript_version.value() != script->meta.ffscript_v)
12785 {
12786 zscript_version.reset();
12787 break;
12788 }
12789 }
12790
12791
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 18 times.
198 if (!zscript_version.has_value())
12792 18 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12793 198 }
12794 398 setZScriptVersion(zscript_version.value_or(s_version));
12795 398 read_scripts.clear();
12796
12797 398 return 0;
12798 398 }
12799
12800 void(*reset_scripts_hook)();
12801
12802 480 void reset_scripts()
12803 {
12804 // We can't modify the script data while jit threads are possibly compiling them.
12805
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 469 times.
480 if (reset_scripts_hook)
12806 469 reset_scripts_hook();
12807
12808
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12809 {
12810
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12811 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12812 245760 }
12813
12814
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12815 {
12816
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (ffscripts[i])
12817 245760 ffscripts[i]->disable();
12818 else
12819 ffscripts[i] = new script_data(ScriptType::FFC, i);
12820 245760 }
12821
12822
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12823 {
12824
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (itemscripts[i])
12825 122880 itemscripts[i]->disable();
12826 else
12827 itemscripts[i] = new script_data(ScriptType::Item, i);
12828 122880 }
12829
12830
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12831 {
12832
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (guyscripts[i])
12833 122880 guyscripts[i]->disable();
12834 else
12835 guyscripts[i] = new script_data(ScriptType::NPC, i);
12836 122880 }
12837
12838
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12839 {
12840
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (screenscripts[i])
12841 122880 screenscripts[i]->disable();
12842 else
12843 screenscripts[i] = new script_data(ScriptType::Screen, i);
12844 122880 }
12845
12846
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 480 times.
4320 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12847 {
12848
1/2
✓ Branch 0 taken 3840 times.
✗ Branch 1 not taken.
3840 if (globalscripts[i])
12849 3840 globalscripts[i]->disable();
12850 else
12851 globalscripts[i] = new script_data(ScriptType::Global, i);
12852 3840 }
12853
12854
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 480 times.
2880 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12855 {
12856
1/2
✓ Branch 0 taken 2400 times.
✗ Branch 1 not taken.
2400 if (playerscripts[i])
12857 2400 playerscripts[i]->disable();
12858 else
12859 playerscripts[i] = new script_data(ScriptType::Hero, i);
12860 2400 }
12861
12862
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12863 {
12864
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (lwpnscripts[i])
12865 122880 lwpnscripts[i]->disable();
12866 else
12867 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12868 122880 }
12869
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12870 {
12871
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (ewpnscripts[i])
12872 122880 ewpnscripts[i]->disable();
12873 else
12874 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12875 122880 }
12876
12877
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12878 {
12879
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (dmapscripts[i])
12880 122880 dmapscripts[i]->disable();
12881 else
12882 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12883 122880 }
12884
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12885 {
12886
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (itemspritescripts[i])
12887 122880 itemspritescripts[i]->disable();
12888 else
12889 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12890 122880 }
12891
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12892 {
12893
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (comboscripts[i])
12894 245760 comboscripts[i]->disable();
12895 else
12896 comboscripts[i] = new script_data(ScriptType::Combo, i);
12897 245760 }
12898
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 122880 times.
123360 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12899 {
12900
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (subscreenscripts[i])
12901 122880 subscreenscripts[i]->disable();
12902 else
12903 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12904 122880 }
12905 480 }
12906
12907 // 3.0+ calls this.
12908 132 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12909 {
12910 int32_t num_commands;
12911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_igetl(&num_commands,f))
12912 return qe_invalid;
12913 #ifdef ZC_FUZZ
12914 const int32_t command_limit = 300000;
12915 #else
12916 132 const int32_t command_limit = 25000000;
12917 #endif
12918
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if (num_commands < 0 || num_commands > command_limit)
12919 return qe_invalid;
12920
12921 132 std::vector<ffscript> zasm;
12922
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 zasm.reserve(num_commands);
12923
2/2
✓ Branch 0 taken 3393884 times.
✓ Branch 1 taken 132 times.
3394016 for(int32_t j=0; j<num_commands; j++)
12924 {
12925
1/2
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
3393884 ffscript temp_script;
12926
2/4
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393884 times.
✗ Branch 3 not taken.
3393884 if(!p_igetw(&(temp_script.command),f))
12927 return qe_invalid;
12928
12929
2/4
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393884 times.
✗ Branch 3 not taken.
3393884 if(!p_igetl(&(temp_script.arg1),f))
12930 return qe_invalid;
12931
12932
2/4
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393884 times.
✗ Branch 3 not taken.
3393884 if(!p_igetl(&(temp_script.arg2),f))
12933 return qe_invalid;
12934
12935
2/4
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393884 times.
✗ Branch 3 not taken.
3393884 if(!p_igetl(&(temp_script.arg3),f))
12936 return qe_invalid;
12937
12938 3393884 uint32_t sz = 0;
12939
2/4
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393884 times.
✗ Branch 3 not taken.
3393884 if(!p_igetl(&sz,f))
12940 return qe_invalid;
12941
2/2
✓ Branch 0 taken 41281 times.
✓ Branch 1 taken 3352603 times.
3393884 if(sz) //string found
12942 {
12943
1/2
✓ Branch 0 taken 41281 times.
✗ Branch 1 not taken.
41281 temp_script.strptr = new std::string();
12944 char dummy;
12945
2/2
✓ Branch 0 taken 752021 times.
✓ Branch 1 taken 41281 times.
793302 for(size_t q = 0; q < sz; ++q)
12946 {
12947
2/4
✓ Branch 0 taken 752021 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 752021 times.
✗ Branch 3 not taken.
752021 if(!p_getc(&dummy,f))
12948 return qe_invalid;
12949
1/2
✓ Branch 0 taken 752021 times.
✗ Branch 1 not taken.
752021 temp_script.strptr->push_back(dummy);
12950 752021 }
12951 41281 }
12952
2/4
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393884 times.
✗ Branch 3 not taken.
3393884 if(!p_igetl(&sz,f))
12953 return qe_invalid;
12954
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 3387387 times.
3393884 if(sz) //vector found
12955 {
12956
1/2
✓ Branch 0 taken 6497 times.
✗ Branch 1 not taken.
6497 temp_script.vecptr = new std::vector<int32_t>();
12957 int32_t dummy;
12958
2/2
✓ Branch 0 taken 18469 times.
✓ Branch 1 taken 6497 times.
24966 for(size_t q = 0; q < sz; ++q)
12959 {
12960
2/4
✓ Branch 0 taken 18469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18469 times.
✗ Branch 3 not taken.
18469 if(!p_igetl(&dummy,f))
12961 return qe_invalid;
12962
1/2
✓ Branch 0 taken 18469 times.
✗ Branch 1 not taken.
18469 temp_script.vecptr->push_back(dummy);
12963 18469 }
12964 6497 }
12965
1/2
✓ Branch 0 taken 3393884 times.
✗ Branch 1 not taken.
3393884 zasm.emplace_back(std::move(temp_script));
12966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3393884 times.
3393884 }
12967
12968
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 assert(zasm_scripts.empty());
12969 132 zasm_script_id id = zasm_scripts.size();
12970
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12971
12972 132 return 0;
12973 132 }
12974
12975 1067142 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12976 {
12977 ASSERT(script);
12978
2/2
✓ Branch 0 taken 558546 times.
✓ Branch 1 taken 508596 times.
1067142 if(s_version < 27)
12979 558546 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
12980
12981 char exists;
12982
1/2
✓ Branch 0 taken 508596 times.
✗ Branch 1 not taken.
508596 if (!p_getc(&exists, f))
12983 return qe_invalid;
12984
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 503934 times.
508596 if (!exists)
12985 {
12986 503934 script->disable();
12987 503934 return 0;
12988 }
12989
12990 //Read meta
12991 {
12992 4662 zasm_meta temp_meta;
12993
12994
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.zasm_v),f))
12995 return qe_invalid;
12996
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.meta_v),f))
12997 return qe_invalid;
12998
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.ffscript_v),f))
12999 return qe_invalid;
13000
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getc(&(temp_meta.script_type),f))
13001 return qe_invalid;
13002
13003
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(int32_t q = 0; q < 8; ++q)
13004 {
13005
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.run_idens[q],f))
13006 return qe_invalid;
13007 37296 }
13008
13009
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 37296 times.
41958 for(int32_t q = 0; q < 8; ++q)
13010
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getc(&(temp_meta.run_types[q]),f))
13011 return qe_invalid;
13012
13013
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getc(&(temp_meta.flags),f))
13014 return qe_invalid;
13015
13016
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v1),f))
13017 return qe_invalid;
13018
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v2),f))
13019 return qe_invalid;
13020
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v3),f))
13021 return qe_invalid;
13022
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v4),f))
13023 return qe_invalid;
13024
13025
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getcstr(&temp_meta.script_name,f))
13026 return qe_invalid;
13027
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getcstr(&temp_meta.author,f))
13028 return qe_invalid;
13029 4662 auto num_meta_attrib = 10;
13030
2/2
✓ Branch 0 taken 46620 times.
✓ Branch 1 taken 4662 times.
51282 for(auto q = 0; q < num_meta_attrib; ++q)
13031 {
13032
2/4
✓ Branch 0 taken 46620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46620 times.
✗ Branch 3 not taken.
46620 if(!p_getcstr(&temp_meta.attributes[q],f))
13033 return qe_invalid;
13034
2/4
✓ Branch 0 taken 46620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46620 times.
✗ Branch 3 not taken.
46620 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13035 return qe_invalid;
13036 46620 }
13037
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(auto q = 0; q < 8; ++q)
13038 {
13039
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.attribytes[q],f))
13040 return qe_invalid;
13041
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13042 return qe_invalid;
13043 37296 }
13044
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(auto q = 0; q < 8; ++q)
13045 {
13046
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13047 return qe_invalid;
13048
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13049 return qe_invalid;
13050 37296 }
13051
2/2
✓ Branch 0 taken 74592 times.
✓ Branch 1 taken 4662 times.
79254 for(auto q = 0; q < 16; ++q)
13052 {
13053
2/4
✓ Branch 0 taken 74592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74592 times.
✗ Branch 3 not taken.
74592 if(!p_getcstr(&temp_meta.usrflags[q],f))
13054 return qe_invalid;
13055
2/4
✓ Branch 0 taken 74592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74592 times.
✗ Branch 3 not taken.
74592 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13056 return qe_invalid;
13057 74592 }
13058
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(auto q = 0; q < 8; ++q)
13059 {
13060
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.initd[q],f))
13061 return qe_invalid;
13062
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getwstr(&temp_meta.initd_help[q],f))
13063 return qe_invalid;
13064 37296 }
13065
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 37296 times.
41958 for(auto q = 0; q < 8; ++q)
13066 {
13067
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getc(&temp_meta.initd_type[q],f))
13068 return qe_invalid;
13069 37296 }
13070
13071
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 script->meta = temp_meta;
13072
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
4662 }
13073
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 if(!p_igetl(&script->pc, f))
13074 return qe_invalid;
13075
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 if(!p_igetl(&script->end_pc, f))
13076 return qe_invalid;
13077
13078
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 if (script == &fake_script_data)
13079 return 0;
13080
13081
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 assert(zasm_scripts.size() == 1);
13082 4662 auto& zs = zasm_scripts[0];
13083 4662 script->zasm_script = zs;
13084
13085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4662 times.
4662 if (script->valid())
13086 {
13087 4662 zs->script_datas.push_back(script);
13088 4662 read_scripts.push_back(script);
13089 4662 }
13090
13091 4662 return 0;
13092 1067142 }
13093
13094 558546 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13095 {
13096 558546 char b33[34] = {0};
13097 558546 b33[33] = 0;
13098 558546 int32_t num_commands=1000;
13099
13100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558546 times.
558546 if(s_version>=2)
13101 {
13102
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 if(!p_igetl(&num_commands,f))
13103 {
13104 return qe_invalid;
13105 }
13106 558546 }
13107
13108 #ifdef ZC_FUZZ
13109 const int32_t command_limit = 300000;
13110 #else
13111 558546 const int32_t command_limit = 10000000;
13112 #endif
13113
2/4
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 558546 times.
558546 if (num_commands < 0 || num_commands > command_limit)
13114 {
13115 return qe_invalid;
13116 }
13117
13118 558546 std::vector<ffscript> zasm;
13119
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 zasm.reserve(num_commands);
13120
13121
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 308600 times.
558546 if(s_version >= 16)
13122 {
13123
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13124
13125
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13126 {
13127 return qe_invalid;
13128 }
13129
13130
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13131 {
13132 return qe_invalid;
13133 }
13134
13135
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13136 {
13137 return qe_invalid;
13138 }
13139
13140
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13141 {
13142 return qe_invalid;
13143 }
13144
13145
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13146 {
13147
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13148 {
13149
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13150 {
13151
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13152 {
13153 return qe_invalid;
13154 }
13155 4748040 }
13156
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13157 143880 }
13158 else
13159 {
13160
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13161 {
13162 return qe_invalid;
13163 }
13164 }
13165 1999568 }
13166
13167
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13168 {
13169
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13170 {
13171 return qe_invalid;
13172 }
13173 1999568 }
13174
13175
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13176 {
13177 return qe_invalid;
13178 }
13179
13180
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13181 {
13182 return qe_invalid;
13183 }
13184
13185
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13186 {
13187 return qe_invalid;
13188 }
13189
13190
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13191 {
13192 return qe_invalid;
13193 }
13194
13195
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13196 {
13197 return qe_invalid;
13198 }
13199
13200
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13201 {
13202
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13203 {
13204
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13205 {
13206 return qe_invalid;
13207 }
13208 593505 }
13209
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13210
13211
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13212 {
13213
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13214 {
13215 return qe_invalid;
13216 }
13217 593505 }
13218
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13219 17985 }
13220
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13221 {
13222
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13223 return qe_invalid;
13224
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13225 return qe_invalid;
13226 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13227
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13228 {
13229
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13230 return qe_invalid;
13231
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13232 return qe_invalid;
13233 2319610 }
13234
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13235 {
13236
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13237 return qe_invalid;
13238
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13239 return qe_invalid;
13240 1855688 }
13241
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13242 {
13243
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13244 return qe_invalid;
13245
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13246 return qe_invalid;
13247 1855688 }
13248
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13249 {
13250
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13251 return qe_invalid;
13252
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13253 return qe_invalid;
13254 3711376 }
13255 231961 }
13256
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13257 {
13258
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13259 {
13260
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13261 return qe_invalid;
13262
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13263 return qe_invalid;
13264 1855688 }
13265
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13266 {
13267
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13268 return qe_invalid;
13269 1855688 }
13270 231961 }
13271 else
13272 {
13273
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13274 {
13275
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13276 143880 }
13277 }
13278
13279
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13280
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 308600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 308600 times.
✗ Branch 5 not taken.
558546 } else script->meta = {};
13281
13282
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 106040107 times.
106114781 for(int32_t j=0; j<num_commands; j++)
13283 {
13284
1/2
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
106040107 auto& sc = zasm.emplace_back();
13285
2/4
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106040107 times.
✗ Branch 3 not taken.
106040107 if(!p_igetw(&sc.command,f))
13286 {
13287 return qe_invalid;
13288 }
13289
13290
2/2
✓ Branch 0 taken 105556235 times.
✓ Branch 1 taken 483872 times.
106040107 if(sc.command == 0xFFFF)
13291 483872 break;
13292 else
13293 {
13294
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg1,f))
13295 {
13296 return qe_invalid;
13297 }
13298
13299
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg2,f))
13300 {
13301 return qe_invalid;
13302 }
13303
13304
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 104508488 times.
105556235 if(s_version >= 24)
13305
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13306 return qe_invalid;
13307
13308
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 97334198 times.
105556235 if(s_version >= 21)
13309 {
13310 8222037 uint32_t sz = 0;
13311
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13312 {
13313 return qe_invalid;
13314 }
13315
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13316 {
13317
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13318 char dummy;
13319
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13320 {
13321
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13322 {
13323 return qe_invalid;
13324 }
13325
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13326 1165008 }
13327 19400 }
13328
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13329 {
13330 return qe_invalid;
13331 }
13332
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13333 {
13334
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13335 int32_t dummy;
13336
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13337 {
13338
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13339 {
13340 return qe_invalid;
13341 }
13342
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13343 11526 }
13344 933 }
13345 8222037 }
13346 }
13347 105556235 }
13348
13349
2/2
✓ Branch 0 taken 490450 times.
✓ Branch 1 taken 68096 times.
558546 if (script == &fake_script_data)
13350 68096 return 0;
13351
13352 // If the first command is unknown, invalidate the whole thing.
13353 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13354
5/6
✓ Branch 0 taken 421152 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 409175 times.
✓ Branch 3 taken 11977 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 409175 times.
490450 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13355 {
13356 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13357 zasm.clear();
13358 }
13359
13360 490450 zasm_script_id id = zasm_scripts.size();
13361
3/6
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 490450 times.
✗ Branch 5 not taken.
490450 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13362 490450 script->zasm_script = zs;
13363 490450 script->pc = 0;
13364 490450 script->end_pc = zs->size;
13365
3/4
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11977 times.
✓ Branch 3 taken 478473 times.
490450 if (script->valid())
13366 {
13367
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 zs->script_datas.push_back(script);
13368
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 read_scripts.push_back(script);
13369 11977 }
13370
13371 490450 return 0;
13372 558546 }
13373
13374 extern SAMPLE customsfxdata[WAV_COUNT];
13375 extern uint8_t customsfxflag[WAV_COUNT>>3];
13376 extern int32_t sfxdat;
13377 extern DATAFILE *sfxdata;
13378 const char *old_sfx_string[Z35] =
13379 {
13380 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13381 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13382 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13383 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13384 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13385 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13386 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13387 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13388 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13389 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13390 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13391 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13392 };
13393 char *sfx_string[WAV_COUNT];
13394
13395 398 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13396 {
13397 //these are here to bypass compiler warnings about unused arguments
13398 398 Header=Header;
13399
13400 int32_t dummy;
13401 398 word s_version=0;
13402 //int32_t ret;
13403 398 SAMPLE temp_sample = {};
13404 398 temp_sample.loop_start=0;
13405 398 temp_sample.loop_end=0;
13406 398 temp_sample.param=0;
13407
13408 //section version info
13409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
13410 {
13411 return qe_invalid;
13412 }
13413
13414 398 FFCore.quest_format[vSFX] = s_version;
13415
13416
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
13417 {
13418 return qe_invalid;
13419 }
13420
13421 //section size
13422
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
13423 {
13424 return qe_invalid;
13425 }
13426
13427 /* HIGHLY UNORTHODOX UPDATING THING, by L
13428 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13429 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13430 * changing from 1 to 2.
13431 */
13432
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 2)
13433 set_qr(qr_GOTOLESSNOTEQUAL,1);
13434
13435 /* End highly unorthodox updating thing */
13436
13437 398 int32_t wavcount = WAV_COUNT;
13438
13439
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 6)
13440 wavcount = 128;
13441
13442 uint8_t tempflag[WAV_COUNT>>3];
13443
13444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version < 4)
13445 {
13446 memset(tempflag, 0xFF, WAV_COUNT>>3);
13447 }
13448 else
13449 {
13450
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 6)
13451 memset(tempflag, 0, WAV_COUNT>>3);
13452
13453
2/2
✓ Branch 0 taken 12736 times.
✓ Branch 1 taken 398 times.
13134 for(int32_t i=0; i<(wavcount>>3); i++)
13454 {
13455 12736 p_getc(&tempflag[i], f);
13456 12736 }
13457
13458 }
13459
13460
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version>4)
13461 {
13462
2/2
✓ Branch 0 taken 101490 times.
✓ Branch 1 taken 398 times.
101888 for(int32_t i=1; i<WAV_COUNT; i++)
13463 {
13464 101490 sprintf(sfx_string[i],"s%03d",i);
13465
13466
2/2
✓ Branch 0 taken 77610 times.
✓ Branch 1 taken 23880 times.
101490 if((i<Z35))
13467 23880 strcpy(sfx_string[i], old_sfx_string[i-1]);
13468
13469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101490 times.
101490 if(i>=wavcount)
13470 continue;
13471
2/2
✓ Branch 0 taken 20870 times.
✓ Branch 1 taken 80620 times.
101490 if(get_bit(tempflag, i-1))
13472 {
13473 char tempname[36];
13474
13475
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!pfread(tempname, 36, f))
13476 {
13477 return qe_invalid;
13478 }
13479
13480 20870 sfx_string[i][0] = '\0';
13481 20870 strncat(sfx_string[i], tempname, 36 - 1);
13482 20870 }
13483 else
13484 {
13485 80620 sprintf(sfx_string[i],"s%03d",i);
13486
13487
2/2
✓ Branch 0 taken 70930 times.
✓ Branch 1 taken 9690 times.
80620 if(i<Z35)
13488 9690 strcpy(sfx_string[i], old_sfx_string[i-1]);
13489 80620 sfx_string[i][35] = 0; //Force NULL Termination
13490 }
13491 101490 }
13492 398 }
13493 else
13494 {
13495 for(int32_t i=1; i<WAV_COUNT; i++)
13496 {
13497 sprintf(sfx_string[i],"s%03d",i);
13498
13499 if(i<Z35)
13500 strcpy(sfx_string[i], old_sfx_string[i-1]);
13501 }
13502 }
13503
13504 //finally... section data
13505
2/2
✓ Branch 0 taken 101490 times.
✓ Branch 1 taken 398 times.
101888 for(int32_t i=1; i<wavcount; i++)
13506 {
13507
2/2
✓ Branch 0 taken 20870 times.
✓ Branch 1 taken 80620 times.
101490 if(get_bit(tempflag, i-1))
13508 {
13509
13510
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13511 {
13512 return qe_invalid;
13513 }
13514
13515 20870 (temp_sample.bits) = dummy;
13516
13517
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13518 {
13519 return qe_invalid;
13520 }
13521
13522 20870 (temp_sample.stereo) = dummy;
13523
13524
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13525 {
13526 return qe_invalid;
13527 }
13528
13529 20870 (temp_sample.freq) = dummy;
13530
13531
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13532 {
13533 return qe_invalid;
13534 }
13535
13536 20870 (temp_sample.priority) = dummy;
13537
13538
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.len),f))
13539 {
13540 return qe_invalid;
13541 }
13542
13543
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.loop_start),f))
13544 {
13545 return qe_invalid;
13546 }
13547
13548
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.loop_end),f))
13549 {
13550 return qe_invalid;
13551 }
13552
13553
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.param),f))
13554 {
13555 return qe_invalid;
13556 }
13557
13558 20870 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13559 #ifdef ZC_FUZZ
13560 const int32_t sfx_limit = 100000;
13561 if (len < 0 || len > sfx_limit)
13562 {
13563 return qe_invalid;
13564 }
13565 #endif
13566 20870 temp_sample.data = calloc(len,1);
13567
13568
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(s_version < 3)
13569 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13570
13571 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20870 times.
20870 if(s_version < 2)
13573 {
13574 if(!pfread(temp_sample.data, len,f))
13575 {
13576 return qe_invalid;
13577 }
13578 }
13579 else
13580 {
13581 //re-endianfy the data
13582 20870 int32_t wordstoread = len / sizeof(word);
13583
13584
2/2
✓ Branch 0 taken 574262528 times.
✓ Branch 1 taken 20870 times.
574283398 for(int32_t j=0; j<wordstoread; j++)
13585 {
13586 word temp;
13587
13588
1/2
✓ Branch 0 taken 574262528 times.
✗ Branch 1 not taken.
574262528 if(!p_igetw(&temp, f))
13589 {
13590 return qe_invalid;
13591 }
13592
13593 574262528 ((word *)temp_sample.data)[j] = temp;
13594 574262528 }
13595 }
13596 20870 }
13597
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 70930 times.
80620 else if(i < Z35)
13598 {
13599 9690 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13600 9690 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13601 9690 set_bit(tempflag, i-1, 1);
13602 9690 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13603 9690 temp_sample.data = calloc(len,1);
13604 9690 memcpy(temp_sample.data, datsamp->data, len);
13605 9690 }
13606 70930 else continue;
13607
13608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30560 times.
30560 if(customsfxdata[i].data!=NULL)
13609 {
13610 // delete [] customsfxdata[i].data;
13611 30560 free(customsfxdata[i].data);
13612 30560 }
13613
13614 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13615 30560 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13616 30560 customsfxdata[i].data = calloc(len2,1);
13617 30560 customsfxdata[i].bits = temp_sample.bits;
13618 30560 customsfxdata[i].stereo = temp_sample.stereo;
13619 30560 customsfxdata[i].freq = temp_sample.freq;
13620 30560 customsfxdata[i].priority = temp_sample.priority;
13621 30560 customsfxdata[i].len = temp_sample.len;
13622 30560 customsfxdata[i].loop_start = temp_sample.loop_start;
13623 30560 customsfxdata[i].loop_end = temp_sample.loop_end;
13624 30560 customsfxdata[i].param = temp_sample.param;
13625 30560 int32_t cpylen = len2;
13626
13627
1/2
✓ Branch 0 taken 30560 times.
✗ Branch 1 not taken.
30560 if(s_version<3)
13628 {
13629 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13630 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13631 }
13632
13633 30560 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13634
13635 30560 free(temp_sample.data);
13636 30560 }
13637
13638 398 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13639
13640 398 sfxdat=0;
13641 398 return 0;
13642 398 }
13643
13644 480 void setupsfx()
13645 {
13646
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=1; i<WAV_COUNT; i++)
13647 {
13648 122400 sprintf(sfx_string[i],"s%03d",i);
13649
13650
2/2
✓ Branch 0 taken 93600 times.
✓ Branch 1 taken 28800 times.
122400 if(i<Z35)
13651 {
13652 28800 strcpy(sfx_string[i], old_sfx_string[i-1]);
13653 28800 }
13654
13655 122400 memset(customsfxflag, 0, WAV_COUNT>>3);
13656
13657 122400 int32_t j=i;
13658
13659
2/2
✓ Branch 0 taken 29280 times.
✓ Branch 1 taken 93120 times.
122400 if(i>Z35)
13660 {
13661 93120 i=Z35;
13662 93120 }
13663
13664 122400 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13665
13666
2/2
✓ Branch 0 taken 94605 times.
✓ Branch 1 taken 27795 times.
122400 if(customsfxdata[j].data!=NULL)
13667 {
13668 // delete [] customsfxdata[j].data;
13669 27795 free(customsfxdata[j].data);
13670 27795 }
13671
13672 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13673 122400 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13674 122400 customsfxdata[j].bits = temp_sample->bits;
13675 122400 customsfxdata[j].stereo = temp_sample->stereo;
13676 122400 customsfxdata[j].freq = temp_sample->freq;
13677 122400 customsfxdata[j].priority = temp_sample->priority;
13678 122400 customsfxdata[j].len = temp_sample->len;
13679 122400 customsfxdata[j].loop_start = temp_sample->loop_start;
13680 122400 customsfxdata[j].loop_end = temp_sample->loop_end;
13681 122400 customsfxdata[j].param = temp_sample->param;
13682 122400 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13683 122400 i=j;
13684 122400 }
13685 480 }
13686
13687 extern char *guy_string[eMAXGUYS];
13688 extern const char *old_guy_string[OLDMAXGUYS];
13689
13690 480 int32_t readguys(PACKFILE *f, zquestheader *Header)
13691 {
13692
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (should_skip) return 0;
13694
13695 dword dummy;
13696 word guy_cversion;
13697 480 word guyversion=0;
13698
13699
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version >= 0x193)
13700 {
13701 //section version info
13702
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&guyversion,f))
13703 {
13704 return qe_invalid;
13705 }
13706
13707 457 FFCore.quest_format[vGuys] = guyversion;
13708
13709 // Note: this is the only instance where "cversion" is ever used.
13710
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&guy_cversion,f))
13711 {
13712 return qe_invalid;
13713 }
13714
13715 //section size
13716
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
13717 {
13718 return qe_invalid;
13719 }
13720 457 }
13721
13722
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(guyversion > 3)
13723 {
13724
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 398 times.
204174 for(int32_t i=0; i<MAXGUYS; i++)
13725 {
13726 char tempname[64];
13727
13728 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13729 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13731 {
13732 memset(tempname, 0, sizeof(char)*64);
13733 sprintf(tempname, "e%03d", i);
13734 strcpy(guy_string[i], tempname);
13735
13736 continue;
13737 }
13738
13739
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!pfread(tempname, 64, f))
13740 {
13741 return qe_invalid;
13742 }
13743
13744 // Don't retain names of uneditable enemy entries!
13745 // for version upgrade to 2.5
13746
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(guyversion < 23 && i >= 177)
13747 {
13748 // some of the older builds have names such as 'zz123',
13749 // (this order gets messed up with some eXXX and some zzXXX)
13750 // so let's update to the newer naming convection. -Gleeok
13751 char tmpbuf[64];
13752 memset(tmpbuf, 0, sizeof(char)*64);
13753 sprintf(tmpbuf, "zz%03d", i);
13754
13755 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13756 {
13757 memset(tempname, 0, sizeof(char)*64);
13758 sprintf(tempname, "e%03d", i);
13759 }
13760 }
13761
13762
6/6
✓ Branch 0 taken 70446 times.
✓ Branch 1 taken 133330 times.
✓ Branch 2 taken 66864 times.
✓ Branch 3 taken 3582 times.
✓ Branch 4 taken 58274 times.
✓ Branch 5 taken 8590 times.
203776 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13763 {
13764 195186 guy_string[i][0] = '\0';
13765 195186 strncat(guy_string[i], tempname, 64 - 1);
13766 195186 }
13767 else
13768 {
13769 8590 strcpy(guy_string[i],old_guy_string[i]);
13770 }
13771 203776 }
13772 398 }
13773 else
13774 {
13775
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13776 {
13777 41984 sprintf(guy_string[i],"zz%03d",i);
13778 41984 }
13779
13780
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13781 {
13782 14514 strcpy(guy_string[i],old_guy_string[i]);
13783 14514 }
13784 }
13785
13786
13787 //finally... section data
13788 480 init_guys(guyversion); //using default data for now...
13789
13790 // Goriya guy fix
13791
3/6
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13792 {
13793
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13794 {
13795 60 guysbuf[gGORIYA].tile=130;
13796 60 guysbuf[gGORIYA].e_tile=130;
13797 60 }
13798 82 }
13799
13800
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 if(Header->zelda_version < 0x193)
13801 {
13802
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13803 {
13804 5 guysbuf[eDODONGO].cset=14;
13805 5 guysbuf[eDODONGO].bosspal=spDIG;
13806 5 }
13807 23 }
13808 // Not sure when this first changed, but it's necessary for 2.10, at least
13809 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13810 //2.10 Fixes
13811
3/6
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13812 {
13813 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13814 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13815 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13816 82 guysbuf[eCENT1].attributes[2] = 1;
13817 82 guysbuf[eCENT2].attributes[2] = 1;
13818 82 }
13819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13820 {
13821 480 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13822 480 }
13823
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(Header->zelda_version <= 0x210)
13824 {
13825 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13826 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13827 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13828 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13829
13830 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13831 82 guysbuf[eBATROBE].attributes[3] = 1;
13832 //guysbuf[eSUMMONER].misc4 = 1;
13833 82 guysbuf[eWWIZ].attributes[3] = 1;
13834 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13835 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13836 82 }
13837
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 12 times.
480 if(Header->zelda_version == 0x190)
13838 {
13839 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13840 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13841 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13842 12 }
13843
13844 // The versions here may not be correct
13845 // zelda_version>=0x211 handled at guyversion<24
13846
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 462 times.
480 if(Header->zelda_version <= 0x190)
13847 {
13848 18 guysbuf[eCENT1].attributes[2] = 0;
13849 18 guysbuf[eCENT2].attributes[2] = 0;
13850 18 guysbuf[eMOLDORM].attributes[1] = 0;
13851 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13852 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13853 18 }
13854
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 64 times.
462 else if(Header->zelda_version <= 0x210)
13855 {
13856 64 guysbuf[eCENT1].attributes[2] = 1;
13857 64 guysbuf[eCENT2].attributes[2] = 1;
13858 64 guysbuf[eMOLDORM].attributes[1] = 0;
13859 64 }
13860
13861
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13862 {
13863 82 guysbuf[eKEESE1].attributes[15] = 120;
13864 82 guysbuf[eKEESE2].attributes[15] = 120;
13865 82 guysbuf[eKEESE3].attributes[15] = 120;
13866 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13867 82 guysbuf[eKEESE1].attributes[16] = 16;
13868 82 guysbuf[eKEESE2].attributes[16] = 16;
13869 82 guysbuf[eKEESE3].attributes[16] = 16;
13870 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13871
13872 82 guysbuf[ePEAHAT].attributes[15] = 80;
13873 82 guysbuf[ePEAHAT].attributes[16] = 16;
13874
13875 82 guysbuf[eGHINI2].attributes[15] = 120;
13876 82 guysbuf[eGHINI2].attributes[16] = 10;
13877
13878
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13879 {
13880 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13881 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13882 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13883 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13884 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13885 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13886 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13887 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13888 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13889 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13890 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13891 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13892 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13893 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13894 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13895 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13896 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13897 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13898 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13899 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13900 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13901 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13902 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13903 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13904 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13905 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13906 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13907 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13908 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13909 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13910 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13911 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13912 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13913 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13914 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13915 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13916 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13917 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13918 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13919 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13920 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13921 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13922 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13923 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13924 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13925 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13926 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13927 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13928 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13929 66 }
13930 82 }
13931
13932
13933
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(guyversion<=2)
13934 {
13935 82 return readherosprites2(f, guyversion==2?0:-1);
13936 }
13937
13938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(guyversion > 3)
13939 {
13940 398 guydata tempguy;
13941
13942
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 398 times.
204174 for(int32_t i=0; i<MAXGUYS; i++)
13943 {
13944
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 23) // May 2012 : 512 max enemies
13945 {
13946 if(i >= OLDBETAMAXGUYS)
13947 {
13948 guysbuf[i].clear();
13949 continue;
13950 }
13951 }
13952
13953 203776 tempguy.clear();
13954
13955 uint32_t flags1;
13956 uint32_t flags2;
13957
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(flags1),f))
13958 {
13959 return qe_invalid;
13960 }
13961
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(flags2),f))
13962 {
13963 return qe_invalid;
13964 }
13965 203776 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13966
13967
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion >= 36 ) //expanded tiles
13968 {
13969
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.tile),f))
13970 {
13971 return qe_invalid;
13972 }
13973 101376 }
13974 else
13975 {
13976
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.tile),f))
13977 {
13978 return qe_invalid;
13979 }
13980 }
13981
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.width),f))
13982 {
13983 return qe_invalid;
13984 }
13985
13986
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.height),f))
13987 {
13988 return qe_invalid;
13989 }
13990
13991
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion >= 36 ) //expanded tiles
13992 {
13993
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.s_tile),f))
13994 {
13995 return qe_invalid;
13996 }
13997 101376 }
13998 else
13999 {
14000
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.s_tile),f))
14001 {
14002 return qe_invalid;
14003 }
14004 }
14005
14006
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.s_width),f))
14007 {
14008 return qe_invalid;
14009 }
14010
14011
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.s_height),f))
14012 {
14013 return qe_invalid;
14014 }
14015
14016
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion >= 36 ) //expanded tiles
14017 {
14018
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.e_tile),f))
14019 {
14020 return qe_invalid;
14021 }
14022 101376 }
14023 else
14024 {
14025
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.e_tile),f))
14026 {
14027 return qe_invalid;
14028 }
14029 }
14030
14031
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.e_width),f))
14032 {
14033 return qe_invalid;
14034 }
14035
14036
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.e_height),f))
14037 {
14038 return qe_invalid;
14039 }
14040
14041
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.hp),f))
14042 {
14043 return qe_invalid;
14044 }
14045
14046
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.type),f))
14047 {
14048 return qe_invalid;
14049 }
14050
14051
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
203776 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14052 {
14053 if(get_qr(qr_NEWENEMYTILES))
14054 {
14055 tempguy.s_tile=tempguy.e_tile+120;
14056 tempguy.s_width=tempguy.e_width;
14057 tempguy.s_height=tempguy.e_height;
14058 }
14059 else tempguy.s_tile=860;
14060 }
14061
14062
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.cset),f))
14063 {
14064 return qe_invalid;
14065 }
14066
14067
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.anim),f))
14068 {
14069 return qe_invalid;
14070 }
14071
14072
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.e_anim),f))
14073 {
14074 return qe_invalid;
14075 }
14076
14077
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.frate),f))
14078 {
14079 return qe_invalid;
14080 }
14081
14082
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.e_frate),f))
14083 {
14084 return qe_invalid;
14085 }
14086
14087
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 13) // April 2009
14088 {
14089 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14090 {
14091 tempguy.frate *= 2;
14092 tempguy.e_frate *= 2;
14093 }
14094 }
14095
14096
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 14) // May 1 2009
14097 {
14098 if(tempguy.anim==a2FRMSLOW)
14099 {
14100 tempguy.anim=a2FRM;
14101 tempguy.frate *= 2;
14102 }
14103
14104 if(tempguy.e_anim==a2FRMSLOW)
14105 {
14106 tempguy.e_anim=a2FRM;
14107 tempguy.e_frate *= 2;
14108 }
14109
14110 if(tempguy.anim==aFLIPSLOW)
14111 {
14112 tempguy.anim=aFLIP;
14113 tempguy.frate *= 2;
14114 }
14115
14116 if(tempguy.e_anim==aFLIPSLOW)
14117 {
14118 tempguy.e_anim=aFLIP;
14119 tempguy.e_frate *= 2;
14120 }
14121
14122 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14123
14124 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14125
14126 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14127 {
14128 tempguy.anim=a4FRM4DIR;
14129 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14130 }
14131
14132 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14133 {
14134 tempguy.e_anim=a4FRM4DIR;
14135 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14136 }
14137 }
14138
14139
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.dp),f))
14140 {
14141 return qe_invalid;
14142 }
14143
14144 //correction for guy fire
14145
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 6)
14146 {
14147 if(i == gFIRE)
14148 tempguy.dp = 2;
14149 }
14150
14151
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.wdp),f))
14152 {
14153 return qe_invalid;
14154 }
14155
14156
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.weapon),f))
14157 {
14158 return qe_invalid;
14159 }
14160
14161 //correction for bosses using triple, "rising" fireballs
14162
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 5)
14163 {
14164 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14165 i == eGOHMA3 || i == eGOHMA4)
14166 {
14167 if(tempguy.weapon == ewFireball)
14168 tempguy.weapon = ewFireball2;
14169 }
14170 }
14171
14172
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.rate),f))
14173 {
14174 return qe_invalid;
14175 }
14176
14177
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.hrate),f))
14178 {
14179 return qe_invalid;
14180 }
14181
14182
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.step),f))
14183 {
14184 return qe_invalid;
14185 }
14186
14187 // HIGHLY UNORTHODOX UPDATING THING, part 2
14188
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(fixpolsvoice && tempguy.type==eePOLSV)
14189 {
14190 tempguy.step /= 2;
14191 }
14192
14193
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.homing),f))
14194 {
14195 return qe_invalid;
14196 }
14197
14198
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.grumble),f))
14199 {
14200 return qe_invalid;
14201 }
14202
14203
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.item_set),f))
14204 {
14205 return qe_invalid;
14206 }
14207
14208
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14209 {
14210
2/2
✓ Branch 0 taken 2037760 times.
✓ Branch 1 taken 203776 times.
2241536 for (int q = 0; q < 10; ++q)
14211 {
14212
1/2
✓ Branch 0 taken 2037760 times.
✗ Branch 1 not taken.
2037760 if (!p_igetl(&(tempguy.attributes[q]), f))
14213 {
14214 return qe_invalid;
14215 }
14216 2037760 }
14217 203776 }
14218 else
14219 {
14220 int16_t tempMisc;
14221
14222 for(int q=0;q<10;q++)
14223 {
14224 if (!p_igetw(&tempMisc, f))
14225 {
14226 return qe_invalid;
14227 }
14228 tempguy.attributes[q] = tempMisc;
14229 }
14230
14231 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14232 {
14233 if(tempguy.type == eeWIZZ && !(tempguy.attributes[0]))
14234 tempguy.attributes[4] = 74;
14235 }
14236
14237 }
14238
14239
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.bgsfx),f))
14240 {
14241 return qe_invalid;
14242 }
14243
14244
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.bosspal),f))
14245 {
14246 return qe_invalid;
14247 }
14248
14249
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.extend),f))
14250 {
14251 return qe_invalid;
14252 }
14253
14254 //! Enemy Defences
14255
14256 //If a 2.50 quest, use only the 2.5 defences.
14257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
203776 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14258 {
14259
2/2
✓ Branch 0 taken 3871744 times.
✓ Branch 1 taken 203776 times.
4075520 for(int32_t j=0; j<edefLAST; j++)
14260 {
14261
1/2
✓ Branch 0 taken 3871744 times.
✗ Branch 1 not taken.
3871744 if(!p_getc(&(tempguy.defense[j]),f))
14262 {
14263 return qe_invalid;
14264 }
14265 3871744 }
14266 //then copy the generic script defence to all the new script defences
14267
14268 203776 }
14269
14270
14271
14272
14273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
203776 if(guyversion >= 18)
14274 {
14275
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.hitsfx),f))
14276 {
14277 return qe_invalid;
14278 }
14279
14280
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.deadsfx),f))
14281 {
14282 return qe_invalid;
14283 }
14284 203776 }
14285
14286
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion >= 22)
14287 {
14288
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(tempguy.attributes[10]), f))
14289 {
14290 return qe_invalid;
14291 }
14292
14293
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(tempguy.attributes[11]),f))
14294 {
14295 return qe_invalid;
14296 }
14297 203776 }
14298 else if(guyversion >= 19)
14299 {
14300 int16_t tempMisc;
14301
14302 if(!p_igetw(&tempMisc,f))
14303 {
14304 return qe_invalid;
14305 }
14306
14307 tempguy.attributes[10] = tempMisc;
14308
14309 if(!p_igetw(&tempMisc,f))
14310 {
14311 return qe_invalid;
14312 }
14313
14314 tempguy.attributes[11] = tempMisc;
14315 }
14316
14317 //If a 2.54 or later quest, use all of the defences.
14318
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 24) // Add new guyversion conditional statement
14319 {
14320
2/2
✓ Branch 0 taken 2230272 times.
✓ Branch 1 taken 101376 times.
2331648 for(int32_t j=edefLAST; j<edefLAST255; j++)
14321 {
14322
1/2
✓ Branch 0 taken 2230272 times.
✗ Branch 1 not taken.
2230272 if(!p_getc(&(tempguy.defense[j]),f))
14323 {
14324 return qe_invalid;
14325 }
14326 2230272 }
14327 101376 }
14328
14329
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14330 {
14331
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14332 {
14333 1024000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14334 1024000 }
14335 102400 }
14336
14337 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14338
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 25)
14339 {
14340
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.txsz),f))
14341 {
14342 return qe_invalid;
14343 }
14344
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.tysz),f))
14345 {
14346 return qe_invalid;
14347 }
14348
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hxsz),f))
14349 {
14350 return qe_invalid;
14351 }
14352
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hysz),f))
14353 {
14354 return qe_invalid;
14355 }
14356
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hzsz),f))
14357 {
14358 return qe_invalid;
14359 }
14360 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14361
14362 */
14363 101376 }
14364 //More Enemy Editor vars for 2.60
14365
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 26)
14366 {
14367
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hxofs),f))
14368 {
14369 return qe_invalid;
14370 }
14371
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hyofs),f))
14372 {
14373 return qe_invalid;
14374 }
14375
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.xofs),f))
14376 {
14377 return qe_invalid;
14378 }
14379
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.yofs),f))
14380 {
14381 return qe_invalid;
14382 }
14383
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.zofs),f))
14384 {
14385 return qe_invalid;
14386 }
14387 101376 }
14388
14389
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14390 {
14391 102400 tempguy.wpnsprite = 0;
14392 102400 }
14393
14394
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 27)
14395 {
14396
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.wpnsprite),f))
14397 {
14398 return qe_invalid;
14399 }
14400 101376 }
14401
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14402 {
14403 102400 tempguy.SIZEflags = 0;
14404 102400 }
14405
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 28)
14406 {
14407
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.SIZEflags),f))
14408 {
14409 return qe_invalid;
14410 }
14411
14412 101376 }
14413
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14414 {
14415 102400 tempguy.frozentile = 0;
14416 102400 tempguy.frozencset = 0;
14417 102400 tempguy.frozenclock = 0;
14418
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14419 102400 }
14420
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 30)
14421 {
14422
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.frozentile),f))
14423 {
14424 return qe_invalid;
14425 }
14426
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.frozencset),f))
14427 {
14428 return qe_invalid;
14429 }
14430
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.frozenclock),f))
14431 {
14432 return qe_invalid;
14433 }
14434
2/2
✓ Branch 0 taken 1013760 times.
✓ Branch 1 taken 101376 times.
1115136 for ( int32_t q = 0; q < 10; q++ ) {
14435
1/2
✓ Branch 0 taken 1013760 times.
✗ Branch 1 not taken.
1013760 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14436 {
14437 return qe_invalid;
14438 }
14439 1013760 }
14440
14441 101376 }
14442
14443
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 34)
14444 {
14445
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetw(&(tempguy.firesfx),f))
14446 {
14447 return qe_invalid;
14448 }
14449
2/2
✓ Branch 0 taken 1723392 times.
✓ Branch 1 taken 101376 times.
1824768 for(int q=15;q<32;++q)
14450 {
14451
1/2
✓ Branch 0 taken 1723392 times.
✗ Branch 1 not taken.
1723392 if(!p_igetl(&(tempguy.attributes[q]),f))
14452 {
14453 return qe_invalid;
14454 }
14455 1723392 }
14456
14457
2/2
✓ Branch 0 taken 3244032 times.
✓ Branch 1 taken 101376 times.
3345408 for ( int32_t q = 0; q < 32; q++ ) {
14458
1/2
✓ Branch 0 taken 3244032 times.
✗ Branch 1 not taken.
3244032 if(!p_igetl(&(tempguy.movement[q]),f))
14459 {
14460 return qe_invalid;
14461 }
14462 3244032 }
14463
2/2
✓ Branch 0 taken 3244032 times.
✓ Branch 1 taken 101376 times.
3345408 for ( int32_t q = 0; q < 32; q++ ) {
14464
1/2
✓ Branch 0 taken 3244032 times.
✗ Branch 1 not taken.
3244032 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14465 {
14466 return qe_invalid;
14467 }
14468 3244032 }
14469
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetw(&(tempguy.script),f))
14470 {
14471 return qe_invalid;
14472 }
14473
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
14474 {
14475
1/2
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
811008 if(!p_igetl(&(tempguy.initD[q]),f))
14476 {
14477 return qe_invalid;
14478 }
14479 811008 }
14480
2/2
✓ Branch 0 taken 202752 times.
✓ Branch 1 taken 101376 times.
304128 for ( int32_t q = 0; q < 2; q++ )
14481 {
14482 int32_t temp;
14483
1/2
✓ Branch 0 taken 202752 times.
✗ Branch 1 not taken.
202752 if(!p_igetl(&temp,f))
14484 {
14485 return qe_invalid;
14486 }
14487 202752 }
14488
14489 101376 }
14490
14491
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 37)
14492 {
14493
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.editorflags),f))
14494 {
14495 return qe_invalid;
14496 }
14497 101376 }
14498
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14499
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 38)
14500 {
14501
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.attributes[12]),f))
14502 {
14503 return qe_invalid;
14504 }
14505
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.attributes[13]),f))
14506 {
14507 return qe_invalid;
14508 }
14509
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.attributes[14]),f))
14510 {
14511 return qe_invalid;
14512 }
14513
14514 101376 }
14515
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 38 )
14516 {
14517 102400 tempguy.attributes[12] = 0;
14518 102400 tempguy.attributes[13] = 0;
14519 102400 tempguy.attributes[14] = 0;
14520 102400 }
14521
14522
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if ( guyversion >= 39 )
14523 {
14524
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
14525 {
14526
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; w++ )
14527 {
14528
1/2
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
52715520 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14529 {
14530 return qe_invalid;
14531 }
14532 52715520 }
14533
2/2
✓ Branch 0 taken 528384 times.
✓ Branch 1 taken 282624 times.
811008 if(guyversion < 54)
14534 {
14535 byte dummybyte;
14536
2/2
✓ Branch 0 taken 18370560 times.
✓ Branch 1 taken 282624 times.
18653184 for ( int32_t w = 0; w < 65; w++ )
14537
1/2
✓ Branch 0 taken 18370560 times.
✗ Branch 1 not taken.
18370560 if(!p_getc(&dummybyte,f))
14538 return qe_invalid;
14539 282624 }
14540 811008 }
14541
14542
14543 101376 }
14544
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 39 ) //apply old InitD strings to both
14545 {
14546
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ )
14547 {
14548 819200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14549 819200 }
14550 102400 }
14551
4/4
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 66048 times.
✓ Branch 3 taken 35328 times.
203776 if ( guyversion >= 40 && guyversion < 54)
14552
1/2
✓ Branch 0 taken 35328 times.
✗ Branch 1 not taken.
35328 if(!p_igetw(&(tempguy.weap_data.script),f))
14553 return qe_invalid;
14554
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 40 )
14555 102400 tempguy.weap_data.script = 0;
14556 //eweapon script InitD
14557
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if ( guyversion >= 41 )
14558 {
14559
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 35328 times.
101376 if(guyversion < 54)
14560
2/2
✓ Branch 0 taken 282624 times.
✓ Branch 1 taken 35328 times.
317952 for ( int32_t q = 0; q < 8; q++ )
14561
1/2
✓ Branch 0 taken 282624 times.
✗ Branch 1 not taken.
282624 if(!p_igetl(&(tempguy.weap_data.initd[q]),f))
14562 35328 return qe_invalid;
14563
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if ( guy_cversion < 4 )
14564 {
14565 if ( tempguy.type == eeKEESE )
14566 {
14567
14568 if ( !tempguy.attributes[0] )
14569 {
14570 tempguy.attributes[15] = 120;
14571 tempguy.attributes[16] = 16;
14572
14573 }
14574 }
14575 if ( tempguy.type == eePEAHAT )
14576 {
14577 tempguy.attributes[15] = 80;
14578 tempguy.attributes[16] = 16;
14579 }
14580
14581 if ( tempguy.type == eeGHINI )
14582 {
14583 tempguy.attributes[15] = 120;
14584 tempguy.attributes[16] = 10;
14585 }
14586
14587 }
14588 101376 }
14589
14590
14591
14592 //default weapon sprites (quest version < 2.54)
14593 //port over old defaults -Z
14594
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 32)
14595 {
14596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.wpnsprite <= 0 )
14597 {
14598
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14599 {
14600 case wNone:
14601 86878 tempguy.wpnsprite = 0; break;
14602
14603 case wSword:
14604 case wBeam:
14605 case wBrang:
14606 case wBomb:
14607 case wSBomb:
14608 case wLitBomb:
14609 case wLitSBomb:
14610 case wArrow:
14611 case wFire:
14612 case wWhistle:
14613 case wBait:
14614 case wWand:
14615 case wMagic:
14616 case wCatching:
14617 case wWind:
14618 case wRefMagic:
14619 case wRefFireball:
14620 case wRefRock:
14621 case wHammer:
14622 case wHookshot:
14623 case wHSHandle:
14624 case wHSChain:
14625 case wSSparkle:
14626 case wFSparkle:
14627 case wSmack:
14628 case wPhantom:
14629 case wCByrna:
14630 case wRefBeam:
14631 case wStomp:
14632 case lwMax:
14633 case wScript1:
14634 case wScript2:
14635 case wScript3:
14636 case wScript4:
14637 case wScript5:
14638 case wScript6:
14639 case wScript7:
14640 case wScript8:
14641 case wScript9:
14642 case wScript10:
14643 case wIce:
14644 //Cannot use any of these weapons yet.
14645 tempguy.wpnsprite = -1;
14646 break;
14647
14648 case wEnemyWeapons:
14649 2849 case ewFireball: tempguy.wpnsprite = 17; break;
14650
14651 801 case ewArrow: tempguy.wpnsprite = 19; break;
14652 691 case ewBrang: tempguy.wpnsprite = 4; break;
14653 1900 case ewSword: tempguy.wpnsprite = 20; break;
14654 1291 case ewRock: tempguy.wpnsprite = 18; break;
14655 2399 case ewMagic: tempguy.wpnsprite = 21; break;
14656 206 case ewBomb: tempguy.wpnsprite = 78; break;
14657 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14658 448 case ewLitBomb: tempguy.wpnsprite = 76; break;
14659 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14660 906 case ewFireTrail: tempguy.wpnsprite = 80; break;
14661 1802 case ewFlame: tempguy.wpnsprite = 35; break;
14662 229 case ewWind: tempguy.wpnsprite = 36; break;
14663 325 case ewFlame2: tempguy.wpnsprite = 81; break;
14664 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14665 case ewIce: tempguy.wpnsprite = 83; break;
14666 1519 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14667
14668
14669 default: break; //No assign.
14670 }
14671 102400 }
14672 102400 }
14673
14674 //default weapon fire sound (quest version < 2.54)
14675 //port over old defaults and zero new data. -Z
14676
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 34)
14677 {
14678
2/2
✓ Branch 0 taken 3276800 times.
✓ Branch 1 taken 102400 times.
3379200 for ( int32_t q = 0; q < 32; q++ )
14679 {
14680 3276800 tempguy.movement[q] = 0;
14681 3276800 tempguy.new_weapon[q] = 0;
14682
14683 3276800 }
14684
14685 //NPC Script attributes.
14686 102400 tempguy.script = 0; //No scripted enemies existed. -Z
14687
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14688
14689
2/2
✓ Branch 0 taken 1740800 times.
✓ Branch 1 taken 102400 times.
1843200 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14690
14691 //old default sounds
14692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.firesfx <= 0 )
14693 {
14694
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14695 {
14696 case wNone:
14697 86878 tempguy.firesfx = 0; break;
14698
14699 case wSword:
14700 case wBeam:
14701 case wBrang:
14702 case wBomb:
14703 case wSBomb:
14704 case wLitBomb:
14705 case wLitSBomb:
14706 case wArrow:
14707 case wFire:
14708 case wWhistle:
14709 case wBait:
14710 case wWand:
14711 case wMagic:
14712 case wCatching:
14713 case wWind:
14714 case wRefMagic:
14715 case wRefFireball:
14716 case wRefRock:
14717 case wHammer:
14718 case wHookshot:
14719 case wHSHandle:
14720 case wHSChain:
14721 case wSSparkle:
14722 case wFSparkle:
14723 case wSmack:
14724 case wPhantom:
14725 case wCByrna:
14726 case wRefBeam:
14727 case wStomp:
14728 case lwMax:
14729 case wScript1:
14730 case wScript2:
14731 case wScript3:
14732 case wScript4:
14733 case wScript5:
14734 case wScript6:
14735 case wScript7:
14736 case wScript8:
14737 case wScript9:
14738 case wScript10:
14739 case wIce:
14740 //Cannot use any of these weapons yet.
14741 tempguy.firesfx = -1;
14742 break;
14743
14744 case wEnemyWeapons:
14745 2849 case ewFireball: tempguy.firesfx = 40; break;
14746
14747 801 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14748 691 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14749 1900 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14750 1291 case ewRock: tempguy.firesfx = 51; break;
14751 2399 case ewMagic: tempguy.firesfx = 32; break;
14752 206 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14753 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14754 448 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14755 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14756 906 case ewFireTrail: tempguy.firesfx = 13; break;
14757 1802 case ewFlame: tempguy.firesfx = 13; break;
14758 229 case ewWind: tempguy.firesfx = 32; break;
14759 325 case ewFlame2: tempguy.firesfx = 13; break;
14760 case ewFlame2Trail: tempguy.firesfx = 13; break;
14761 case ewIce: tempguy.firesfx = 44; break;
14762 1519 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14763
14764 //what about special attacks (e.g. summoning == 56)
14765 default: break; //No assign.
14766 }
14767 102400 }
14768 102400 }
14769
14770 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14771
4/6
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 101376 times.
203776 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14772 {
14773
2/2
✓ Branch 0 taken 89799 times.
✓ Branch 1 taken 12601 times.
102400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14774 102400 }
14775 //Keese and bat halt rates.
14776
3/4
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102400 times.
203776 if ( guyversion < 42 && guy_cversion < 4 )
14777 {
14778
14779
2/2
✓ Branch 0 taken 101101 times.
✓ Branch 1 taken 1299 times.
102400 if ( tempguy.type == eeKEESE )
14780 {
14781
14782
2/2
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 364 times.
1299 if ( !tempguy.attributes[0] )
14783 {
14784 935 tempguy.attributes[15] = 120;
14785 935 tempguy.attributes[16] = 16;
14786
14787 935 }
14788 1299 }
14789
2/2
✓ Branch 0 taken 101935 times.
✓ Branch 1 taken 465 times.
102400 if ( tempguy.type == eePEAHAT )
14790 {
14791 465 tempguy.attributes[15] = 80;
14792 465 tempguy.attributes[16] = 16;
14793 465 }
14794
2/2
✓ Branch 0 taken 102200 times.
✓ Branch 1 taken 200 times.
102400 if ( tempguy.type == eeGHINI )
14795 {
14796 200 tempguy.attributes[15] = 120;
14797 200 tempguy.attributes[16] = 10;
14798 200 }
14799
14800
14801 102400 }
14802
14803
14804 //miscellaneous other corrections
14805 //fix the mirror wizzrobe -DD
14806
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 7)
14807 {
14808 if(i == eMWIZ)
14809 {
14810 tempguy.attributes[1] = 0;
14811 tempguy.attributes[3] = 1;
14812 }
14813 }
14814
14815
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 8)
14816 {
14817 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14818 {
14819 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14820 tempguy.attributes[4] = 4; //neck length in segments
14821 tempguy.attributes[5] = 8; //neck offset from first body tile
14822 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14823 tempguy.attributes[7] = 168; //head offset from first body tile
14824 tempguy.attributes[8] = 228; //flying head offset from first body tile
14825
14826 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14827 {
14828 tempguy.attributes[5] += 10; //neck offset from first body tile
14829 tempguy.attributes[7] -= 12; //head offset from first body tile
14830 }
14831 }
14832 }
14833
14834
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14835 {
14836 if(get_bit(deprecated_rules,46) && tempguy.type==eeDONGO && tempguy.attributes[0]==0)
14837 tempguy.bosspal = spDIG;
14838 }
14839
14840
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 11) // December 2007 - Spinning Tile fix
14841 {
14842 if(tempguy.type==eeSPINTILE)
14843 {
14844 tempguy.flags |= guy_superman;
14845 tempguy.item_set = 0; // Don't drop items
14846 tempguy.step = 300;
14847 }
14848 }
14849
14850
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14851 {
14852 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14853 {
14854 if(tempguy.type==eeROPE)
14855 {
14856 tempguy.flags &= ~guy_flashing;
14857 }
14858 }
14859
14860 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14861 {
14862 if(tempguy.type==eeBUBBLE)
14863 {
14864 tempguy.flags &= ~guy_flashing;
14865 }
14866 }
14867
14868 if((tempguy.type==eeGHINI)&&(tempguy.attributes[0]))
14869 {
14870 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14871 {
14872 tempguy.flags |= guy_blinking;
14873 }
14874
14875 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14876 {
14877 tempguy.flags |= guy_transparent;
14878 }
14879 }
14880 }
14881
14882
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14883 {
14884 if(i==gFIRE)
14885 {
14886 tempguy.e_anim = aFLIP;
14887 tempguy.e_frate = 24;
14888 }
14889
14890 if(i==gFAIRY)
14891 {
14892 tempguy.e_anim = a2FRM;
14893 tempguy.e_frate = 16;
14894 }
14895 }
14896
14897
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14898 {
14899 if(i==0) Z_message("Updating guys to version 16...\n");
14900
14901 update_guy_1(&tempguy);
14902
14903 if(i==eMPOLSV)
14904 {
14905 tempguy.defense[edefARROW] = edCHINK;
14906 tempguy.defense[edefMAGIC] = ed1HKO;
14907 tempguy.defense[edefREFMAGIC] = ed1HKO;
14908 }
14909 }
14910
14911
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 17) // December 2009
14912 {
14913 if(tempguy.type==eePROJECTILE)
14914 {
14915 tempguy.attributes[0] = 0;
14916 }
14917 }
14918
14919
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 18) // January 2010
14920 {
14921 bool boss = (tempguy.type == eeAQUA || tempguy.type==eeDONGO || tempguy.type == eeMANHAN || tempguy.type == eeGHOMA || tempguy.type==eeDIG
14922 || tempguy.type == eeGLEEOK || tempguy.type==eePATRA || tempguy.type == eeGANON || tempguy.type==eeMOLD);
14923
14924 tempguy.hitsfx = (boss && tempguy.type != eeMOLD && tempguy.type != eeDONGO && tempguy.type != eeDIG) ? WAV_GASP : 0;
14925 tempguy.deadsfx = (boss && (tempguy.type != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14926
14927 if(tempguy.type == eeAQUA)
14928 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14929 else if(tempguy.type == eeMANHAN)
14930 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14931 else if(tempguy.type==eePATRA)
14932 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14933 else if(tempguy.type==eeGHOMA)
14934 {
14935 for(int32_t j=0; j<edefLAST; j++)
14936 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14937
14938 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14939
14940 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14941
14942 tempguy.attributes[0]--;
14943 }
14944 else if(tempguy.type == eeGLEEOK)
14945 {
14946 for(int32_t j=0; j<edefLAST; j++)
14947 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14948
14949 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14950 }
14951 else if(tempguy.type == eeARMOS)
14952 {
14953 tempguy.type=eeWALK;
14954 tempguy.hrate = 0;
14955 tempguy.attributes[9] = tempguy.attributes[0];
14956 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14957 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14958 tempguy.attributes[8] = e9tARMOS;
14959 }
14960 else if(tempguy.type == eeGHINI && !tempguy.attributes[0])
14961 {
14962 tempguy.type=eeWALK;
14963 tempguy.hrate = 0;
14964 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14965 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14966 }
14967
14968 // Spawn animation flags
14969 if(tempguy.type == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14970 tempguy.flags |= guy_fade_flicker;
14971 else
14972 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14973 }
14974
14975
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 20) // April 2010
14976 {
14977 if(tempguy.type == eeTRAP)
14978 {
14979 tempguy.attributes[1] = tempguy.attributes[9];
14980
14981 if(tempguy.attributes[9]>=1)
14982 {
14983 tempguy.attributes[0]++;
14984 }
14985
14986 tempguy.attributes[9] = 0;
14987 }
14988
14989 // Bomb Blast fix
14990 if(tempguy.weapon==ewBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14991 tempguy.weapon = ewLitBomb;
14992 else if(tempguy.weapon==ewSBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14993 tempguy.weapon = ewLitSBomb;
14994 }
14995
14996
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 21) // September 2011
14997 {
14998 if(tempguy.type == eeKEESE || tempguy.type == eeKEESETRIB)
14999 {
15000 if(tempguy.type == eeKEESETRIB)
15001 {
15002 tempguy.type = eeKEESE;
15003 tempguy.attributes[1] = e2tKEESETRIB;
15004 tempguy.attributes[0] = 0;
15005 }
15006
15007 tempguy.rate = 2;
15008 tempguy.hrate = 8;
15009 tempguy.homing = 0;
15010 tempguy.step= (tempguy.type == eeKEESE && tempguy.attributes[0] ? 100:62);
15011 }
15012 else if(tempguy.type == eePEAHAT || tempguy.type==eePATRA)
15013 {
15014 if(tempguy.type == eePEAHAT)
15015 {
15016 tempguy.rate = 4;
15017 tempguy.step = 62;
15018 }
15019 else
15020 tempguy.step = 25;
15021
15022 tempguy.hrate = 8;
15023 tempguy.homing = 0;
15024 }
15025 else if(tempguy.type == eeDIG || tempguy.type == eeMANHAN)
15026 {
15027 if(tempguy.type == eeMANHAN)
15028 tempguy.step=50;
15029
15030 tempguy.hrate = 16;
15031 tempguy.homing = 0;
15032 }
15033 else if(tempguy.type == eeGLEEOK)
15034 {
15035 tempguy.rate = 2;
15036 tempguy.homing = 0;
15037 tempguy.hrate = 9;
15038 tempguy.step=89;
15039 }
15040 else if(tempguy.type == eeGHINI)
15041 {
15042 tempguy.rate = 4;
15043 tempguy.hrate = 12;
15044 tempguy.step=62;
15045 tempguy.homing = 0;
15046 }
15047
15048 // Bigdig random rate fix
15049 if(tempguy.type==eeDIG && tempguy.attributes[9]==1)
15050 {
15051 tempguy.rate = 2;
15052 }
15053 }
15054
15055
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 24) // November 2012
15056 {
15057 if(tempguy.type==eeLANM)
15058 tempguy.attributes[2] = 1;
15059 else if(tempguy.type==eeMOLD)
15060 tempguy.attributes[1] = 0;
15061 }
15062
15063
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15064 {
15065
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 101000 times.
102400 if(tempguy.type!=eeDIG)
15066 {
15067 101000 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15068 101000 }
15069
15070 102400 }
15071 // does not seem to solve the issue!
15072
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if ( Header->zelda_version <= 0x210 )
15073 {
15074 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15075 if ( tempguy.type == eeDONGO )
15076 {
15077 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15078 }
15079 }
15080
15081
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion >= 42)
15082 {
15083
2/2
✓ Branch 0 taken 98816 times.
✓ Branch 1 taken 2560 times.
101376 if(guyversion >= 47)
15084 {
15085
1/2
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
98816 if(!p_igetl(&(tempguy.moveflags),f))
15086 {
15087 return qe_invalid;
15088 }
15089 98816 }
15090 else
15091 {
15092 byte fl;
15093
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
15094 {
15095 return qe_invalid;
15096 }
15097 2560 tempguy.moveflags = (move_flags)fl;
15098 }
15099 101376 }
15100 else
15101 {
15102
7/8
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 80670 times.
✓ Branch 2 taken 2717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 958 times.
✓ Branch 5 taken 642 times.
✓ Branch 6 taken 498 times.
✓ Branch 7 taken 13859 times.
102400 switch(tempguy.type)
15103 {
15104 //No gravity; floats over pits
15105 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15106 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15107 //Special (bosses, etc)
15108 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15109 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15110 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15111 80670 tempguy.moveflags = move_can_pitwalk;
15112 80670 break;
15113 //No gravity, but falls in pits
15114 case eeLEV:
15115 958 tempguy.moveflags = move_can_pitfall;
15116 958 break;
15117 //Bosses that respect pits
15118 case eeDONGO:
15119 642 tempguy.moveflags = move_obeys_grav;
15120 642 break;
15121 case eeLANM:
15122 498 tempguy.moveflags = move_none;
15123 498 break;
15124 //Gravity, floats over pits
15125 case eeWIZZ: case eeWALLM: case eeGHINI:
15126 2717 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15127 2717 break;
15128 //Gravity and falls in pits
15129 case eeWALK:
15130
4/4
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 12635 times.
13859 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15131 1224 break;
15132 [[fallthrough]];
15133 case eeOTHER:
15134 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15135 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15136 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15137 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15138 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15139 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15140 15691 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15141 15691 }
15142 }
15143
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 43)
15144 {
15145
2/2
✓ Branch 0 taken 83387 times.
✓ Branch 1 taken 19013 times.
102400 switch(tempguy.type)
15146 {
15147 //No gravity; floats over pits
15148 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15149 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15150 //Special (bosses, etc)
15151 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15152 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15153 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15154 case eeWIZZ: case eeWALLM: case eeGHINI:
15155 //Gravity, floats over pits
15156 83387 tempguy.moveflags |= move_can_waterwalk;
15157 83387 tempguy.moveflags |= move_can_pitwalk;
15158 83387 break;
15159 }
15160 102400 }
15161
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if (guyversion < 44)
15162 {
15163
2/2
✓ Branch 0 taken 101487 times.
✓ Branch 1 taken 913 times.
102400 if ( tempguy.type == eeGHOMA )
15164 {
15165 913 tempguy.flags |= guy_fade_instant;
15166 913 }
15167 102400 }
15168
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if (guyversion > 44)
15169 {
15170
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&(tempguy.spr_shadow),f))
15171 {
15172 return qe_invalid;
15173 }
15174
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&(tempguy.spr_death),f))
15175 {
15176 return qe_invalid;
15177 }
15178
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&(tempguy.spr_spawn),f))
15179 {
15180 return qe_invalid;
15181 }
15182 101376 }
15183 else
15184 {
15185
2/2
✓ Branch 0 taken 102003 times.
✓ Branch 1 taken 397 times.
102400 tempguy.spr_shadow = (tempguy.type==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15186 102400 tempguy.spr_death = iwDeath;
15187 102400 tempguy.spr_spawn = iwSpawn;
15188 }
15189
15190
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 46)
15191 {
15192
4/4
✓ Branch 0 taken 13859 times.
✓ Branch 1 taken 88541 times.
✓ Branch 2 taken 13164 times.
✓ Branch 3 taken 695 times.
102400 if(tempguy.type == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15193 {
15194 695 tempguy.moveflags |= move_can_waterwalk;
15195 695 }
15196 102400 }
15197
15198
2/2
✓ Branch 0 taken 98816 times.
✓ Branch 1 taken 104960 times.
203776 if (guyversion < 47)
15199 {
15200
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
✓ Branch 2 taken 856 times.
✓ Branch 3 taken 574 times.
104960 if (tempguy.type == eeDIG && tempguy.attributes[9]!=1)
15201 {
15202 574 tempguy.flags |= guy_ignore_kill_all;
15203 574 }
15204 104960 }
15205
15206
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 125440 times.
203776 if (guyversion < 49)
15207 {
15208
8/8
✓ Branch 0 taken 16388 times.
✓ Branch 1 taken 109052 times.
✓ Branch 2 taken 15916 times.
✓ Branch 3 taken 472 times.
✓ Branch 4 taken 15433 times.
✓ Branch 5 taken 483 times.
✓ Branch 6 taken 528 times.
✓ Branch 7 taken 14905 times.
125440 if (tempguy.type == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15209 {
15210
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 712 times.
✓ Branch 3 taken 61 times.
1483 switch (tempguy.attributes[7]) {
15211 case 0: //Sword
15212 710 tempguy.attributes[7] = e8tSWORD;
15213 710 break;
15214 case 1: //Item
15215 712 tempguy.attributes[7] = e8tITEM;
15216 712 break;
15217 case 2: //Both
15218 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15219 61 break;
15220 default: //this can actually happen since Misc8 can be set to any number.
15221 tempguy.attributes[7] = 0;
15222 break;
15223 }
15224 1483 }
15225 125440 }
15226
15227 //these could possible be combined but rather be safe...
15228
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 125440 times.
203776 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15229 {
15230 125440 guy_update_firesfx(tempguy);
15231 125440 }
15232
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 78336 times.
203776 if (guyversion < 52)
15233 {
15234 125440 guy_update_weaponflags(tempguy);
15235 125440 }
15236
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 12288 times.
78336 else if(guyversion < 54)
15237 {
15238
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_getc(&(tempguy.weap_data.unblockable), f))
15239 return qe_invalid;
15240
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.moveflags), f))
15241 return qe_invalid;
15242
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.override_flags), f))
15243 return qe_invalid;
15244
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.tilew), f))
15245 return qe_invalid;
15246
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.tileh), f))
15247 return qe_invalid;
15248
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hxsz), f))
15249 return qe_invalid;
15250
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hysz), f))
15251 return qe_invalid;
15252
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hzsz), f))
15253 return qe_invalid;
15254
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hxofs), f))
15255 return qe_invalid;
15256
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hyofs), f))
15257 return qe_invalid;
15258
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.xofs), f))
15259 return qe_invalid;
15260
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.yofs), f))
15261 return qe_invalid;
15262 int32_t temp_step;
15263
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&temp_step, f))
15264 return qe_invalid;
15265 12288 tempguy.weap_data.step = zslongToFix(temp_step*100);
15266
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 12288 times.
73728 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15267 {
15268
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if (!p_igetw(&(tempguy.weap_data.burnsprs[q]), f))
15269 return qe_invalid;
15270
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if (!p_igetw(&(tempguy.weap_data.light_rads[q]), f))
15271 return qe_invalid;
15272 61440 }
15273 12288 }
15274
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 78336 times.
203776 if (guyversion < 53)
15275 {
15276 125440 guy_update_weaponspecialsfx(tempguy);
15277 125440 }
15278 else
15279 {
15280
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if (!p_getc(&(tempguy.specialsfx), f))
15281 return qe_invalid;
15282 }
15283
15284
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 137728 times.
203776 if(guyversion >= 54)
15285 {
15286
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(auto ret = read_weap_data(tempguy.weap_data, f))
15287 return ret;
15288 66048 }
15289 else
15290 {
15291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137728 times.
137728 SETFLAG(tempguy.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempguy.flags & guy_burning_sprites);
15292 137728 tempguy.weap_data.flags |= wdata_set_step;
15293
2/2
✓ Branch 0 taken 136057 times.
✓ Branch 1 taken 1671 times.
137728 if(tempguy.weapon == ewRock)
15294 1671 tempguy.weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
15295 }
15296
15297
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15298 {
15299 tempguy.script = 0;
15300 for(int q = 0; q < 8; ++q)
15301 tempguy.initD[q] = 0;
15302 }
15303 203776 guysbuf[i] = tempguy;
15304 203776 }
15305 398 }
15306
15307 398 return 0;
15308 480 }
15309
15310 void update_guy_1(guydata *tempguy) // November 2009
15311 {
15312 bool doesntcount = false;
15313 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15314
15315 switch(tempguy->type)
15316 {
15317 case 1: //eeWALK
15318 switch(tempguy->attributes[9])
15319 {
15320 case 0: //Stalfos
15321 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15322 tempguy->attributes[0]=4;
15323
15324 break;
15325
15326 case 1: //Darknut
15327 goto darknuts;
15328 break;
15329 }
15330
15331 tempguy->attributes[9] = 0;
15332 break;
15333
15334 case 2: //eeSHOOT
15335 tempguy->type = eeWALK;
15336
15337 switch(tempguy->attributes[9])
15338 {
15339 case 0: //Octorok
15340 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15341 {
15342 tempguy->attributes[0]=e1tFIREOCTO;
15343 tempguy->attributes[1]=e2tFIREOCTO;
15344 }
15345 else tempguy->attributes[0] = 0;
15346
15347 tempguy->attributes[5]=tempguy->attributes[3];
15348 tempguy->attributes[3]=tempguy->attributes[2];
15349 tempguy->attributes[2]=0;
15350 break;
15351
15352 case 1: // Moblin
15353 tempguy->attributes[0] = 0;
15354 break;
15355
15356 case 2: //Lynel
15357 tempguy->attributes[5]=tempguy->attributes[0]+1;
15358 tempguy->attributes[0]=0;
15359 break;
15360
15361 case 3: //Stalfos 2
15362 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15363 tempguy->attributes[0]=e1t4SHOTS;
15364 else tempguy->attributes[0] = 0;
15365
15366 break;
15367
15368 case 4: //Darknut 5
15369 darknuts:
15370 tempguy->defense[edefFIRE] = edIGNORE;
15371 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15372 tempguy->defense[edefHOOKSHOT] = 0;
15373 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15374 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15375
15376 if(tempguy->attributes[0]==1)
15377 tempguy->attributes[0]=2;
15378 else if(tempguy->attributes[0]==2)
15379 {
15380 tempguy->attributes[3]=tempguy->attributes[2];
15381 tempguy->attributes[2]=tempguy->attributes[1];
15382 tempguy->attributes[1]=e2tSPLIT;
15383 tempguy->attributes[0] = 0;
15384 }
15385 else tempguy->attributes[0] = 0;
15386
15387 tempguy->flags |= guy_shield_front;
15388
15389 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15390 tempguy->flags &= ~guy_bkshield;
15391 else
15392 tempguy->flags |= guy_bkshield;
15393
15394 break;
15395 }
15396
15397 tempguy->attributes[9] = 0;
15398 break;
15399
15400 /*
15401 case 9: //eeARMOS
15402 tempguy->family = eeWALK;
15403 break;
15404 */
15405 case 11: //eeGEL
15406 case 33: //eeGELTRIB
15407 if(tempguy->type==33)
15408 {
15409 tempguy->attributes[3] = 1;
15410
15411 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15412 tempguy->attributes[2] = tempguy->attributes[1];
15413
15414 tempguy->attributes[1] = e2tTRIBBLE;
15415 }
15416 else
15417 {
15418 tempguy->attributes[3] = 0;
15419 tempguy->attributes[2] = 0;
15420 tempguy->attributes[1] = 0;
15421 }
15422
15423 tempguy->type = eeWALK;
15424
15425 if(tempguy->attributes[0])
15426 {
15427 tempguy->attributes[0]=1;
15428 tempguy->weapon = ewFireTrail;
15429 }
15430
15431 break;
15432
15433 case 34: //eeZOLTRIB
15434 case 12: //eeZOL
15435 tempguy->attributes[3]=tempguy->attributes[2];
15436 tempguy->attributes[2]=tempguy->attributes[1];
15437 tempguy->type = eeWALK;
15438 tempguy->attributes[1]=e2tSPLITHIT;
15439
15440 if(tempguy->attributes[0])
15441 {
15442 tempguy->attributes[0]=1;
15443 tempguy->weapon = ewFireTrail;
15444 }
15445
15446 break;
15447
15448 case 13: //eeROPE
15449 tempguy->type = eeWALK;
15450 tempguy->attributes[8] = e9tROPE;
15451
15452 if(tempguy->attributes[0])
15453 {
15454 tempguy->attributes[3] = tempguy->attributes[2];
15455 tempguy->attributes[2] = tempguy->attributes[1];
15456 tempguy->attributes[1] = e2tBOMBCHU;
15457 }
15458
15459 tempguy->attributes[0] = 0;
15460 break;
15461
15462 case 14: //eeGORIYA
15463 tempguy->type = eeWALK;
15464
15465 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15466
15467 break;
15468
15469 case 17: //eeBUBBLE
15470 tempguy->type = eeWALK;
15471 tempguy->attributes[7] = tempguy->attributes[1];
15472 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15473 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15474
15475 //fallthrogh
15476 case eeTRAP:
15477 case eeROCK:
15478 doesntcount = true;
15479 break;
15480
15481 case 35: //eeVIRETRIB
15482 case 18: //eeVIRE
15483 tempguy->type = eeWALK;
15484 tempguy->attributes[3]=tempguy->attributes[2];
15485 tempguy->attributes[2]=tempguy->attributes[1];
15486 tempguy->attributes[1]=e2tSPLITHIT;
15487 tempguy->attributes[8]=e9tVIRE;
15488 break;
15489
15490 case 19: //eeLIKE
15491 tempguy->type = eeWALK;
15492 tempguy->attributes[6] = e7tEATITEMS;
15493 tempguy->attributes[7]=95;
15494 break;
15495
15496 case 20: //eePOLSV
15497 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15498 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15499 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15500 tempguy->defense[edefARROW] = ed1HKO;
15501 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15502 tempguy->type = eeWALK;
15503 tempguy->attributes[8] = e9tPOLSVOICE;
15504 tempguy->rate = 4;
15505 tempguy->homing = 32;
15506 tempguy->hrate = 10;
15507 tempguy->grumble = 0;
15508 break;
15509
15510 case eeWIZZ:
15511 if(tempguy->attributes[3])
15512 {
15513 for(int32_t i=0; i < edefLAST; i++)
15514 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15515 }
15516 else
15517 {
15518 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15519 tempguy->defense[edefMAGIC] = edCHINK;
15520 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15521 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15522 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15523 }
15524
15525 break;
15526
15527 case eePEAHAT:
15528 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15529
15530 if(!(tempguy->flags & guy_bhit))
15531 tempguy->defense[edefBRANG] = edSTUNONLY;
15532
15533 break;
15534
15535 case eeLEV:
15536 tempguy->defense[edefSTOMP] = edCHINK;
15537 break;
15538 }
15539
15540 // Old flags
15541 if(tempguy->flags & guy_superman)
15542 {
15543 for(int32_t i = 0; i < edefLAST; i++)
15544 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15545 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15546 && tempguy->type != eeROCK && tempguy->type != eeTRAP
15547 && tempguy->type != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15548 }
15549
15550 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15551
15552 if(doesntcount)
15553 tempguy->flags |= (guy_doesnt_count);
15554 }
15555
15556 1178856 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15557 {
15558 1178856 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
15559
15560 byte tempbyte, padding;
15561 word wpadding;
15562 int32_t extras, secretcombos;
15563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->valid),f))
15564 {
15565 return qe_invalid;
15566 }
15567
15568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->guy),f))
15569 return qe_invalid;
15570 1178856 temp_mapscr->guytile = -1; //signal to use default guy values
15571
2/2
✓ Branch 0 taken 1178256 times.
✓ Branch 1 taken 600 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15572
4/4
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1178256 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 538 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15573
15574
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15575 {
15576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15577 {
15578 return qe_invalid;
15579 }
15580
15581 22176 temp_mapscr->str=tempbyte;
15582 22176 }
15583 else
15584 {
15585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->str),f))
15586 {
15587 return qe_invalid;
15588 }
15589 }
15590
15591
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->room),f))
15592 {
15593 return qe_invalid;
15594 }
15595
15596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->item),f))
15597 {
15598 return qe_invalid;
15599 }
15600
15601
3/6
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 650352 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15602 {
15603 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15604 528504 }
15605 else
15606 {
15607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->hasitem),f))
15608 return qe_invalid;
15609 }
15610
15611
3/4
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1181576 if((Header->zelda_version < 0x192)||
15612
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15613 {
15614
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15615 {
15616 return qe_invalid;
15617 }
15618 22176 }
15619
15620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15621 {
15622 return qe_invalid;
15623 }
15624
15625
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15626 {
15627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15628 {
15629 return qe_invalid;
15630 }
15631 24896 }
15632
15633
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15634 {
15635
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15636 {
15637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15638 {
15639 return qe_invalid;
15640 }
15641 1951056 }
15642 650352 }
15643 else
15644 {
15645 528504 temp_mapscr->tilewarptype[1]=0;
15646 528504 temp_mapscr->tilewarptype[2]=0;
15647 528504 temp_mapscr->tilewarptype[3]=0;
15648 }
15649
15650
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15651 {
15652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15653 {
15654 return qe_invalid;
15655 }
15656 1156680 }
15657
15658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15659 {
15660 return qe_invalid;
15661 }
15662
15663 1178856 temp_mapscr->warpreturnx[1]=0;
15664 1178856 temp_mapscr->warpreturnx[2]=0;
15665 1178856 temp_mapscr->warpreturnx[3]=0;
15666
15667
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15668 {
15669
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15670 {
15671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15672 {
15673 return qe_invalid;
15674 }
15675 1951056 }
15676 650352 }
15677
15678
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15679 {
15680 return qe_invalid;
15681 }
15682
15683 1178856 temp_mapscr->warpreturny[1]=0;
15684 1178856 temp_mapscr->warpreturny[2]=0;
15685 1178856 temp_mapscr->warpreturny[3]=0;
15686
15687
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15688 {
15689
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15690 {
15691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15692 {
15693 return qe_invalid;
15694 }
15695 1951056 }
15696
15697
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(version>=18)
15698 {
15699
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15700 {
15701 return qe_invalid;
15702 }
15703 650352 }
15704 else
15705 {
15706 byte temp;
15707
15708 if(!p_getc(&temp,f))
15709 {
15710 return qe_invalid;
15711 }
15712
15713 temp_mapscr->warpreturnc=temp<<8|temp;
15714 }
15715 650352 }
15716
15717
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->stairx),f))
15718
15719 {
15720 return qe_invalid;
15721 }
15722
15723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->stairy),f))
15724 {
15725 return qe_invalid;
15726 }
15727
15728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemx),f))
15729 {
15730 return qe_invalid;
15731 }
15732
15733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemy),f))
15734 {
15735 return qe_invalid;
15736 }
15737
15738
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version > 15) // February 2009
15739 {
15740
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->color),f))
15741 {
15742 return qe_invalid;
15743 }
15744 650352 }
15745 else
15746 {
15747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15748 {
15749 return qe_invalid;
15750 }
15751
15752 528504 temp_mapscr->color = (word) tempbyte;
15753 }
15754
15755
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags11),f))
15756 {
15757 return qe_invalid;
15758 }
15759
15760
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
15761 {
15762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->door[k]),f))
15763 {
15764 return qe_invalid;
15765
15766 }
15767 4715424 }
15768
15769
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
15770 {
15771
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15772 {
15773 return qe_invalid;
15774 }
15775
15776 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15777
15778
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15779 {
15780 for(int32_t i=1; i<4; i++)
15781 {
15782 if(!p_getc(&(tempbyte),f))
15783 {
15784 return qe_invalid;
15785 }
15786
15787 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15788 }
15789 }
15790 else
15791 {
15792 528504 temp_mapscr->tilewarpdmap[1]=0;
15793 528504 temp_mapscr->tilewarpdmap[2]=0;
15794 528504 temp_mapscr->tilewarpdmap[3]=0;
15795 }
15796 528504 }
15797 else
15798 {
15799
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
15800 {
15801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15802 {
15803 return qe_invalid;
15804 }
15805 2601408 }
15806 }
15807
15808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15809 {
15810 return qe_invalid;
15811 }
15812
15813
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15814 {
15815
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15816 {
15817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15818 {
15819 return qe_invalid;
15820 }
15821 1951056 }
15822 650352 }
15823 else
15824 {
15825 528504 temp_mapscr->tilewarpscr[1]=0;
15826 528504 temp_mapscr->tilewarpscr[2]=0;
15827 528504 temp_mapscr->tilewarpscr[3]=0;
15828 }
15829
15830
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15831 {
15832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15833 {
15834 return qe_invalid;
15835 }
15836 650352 }
15837 else
15838 {
15839 528504 temp_mapscr->tilewarpoverlayflags=0;
15840 }
15841
15842
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->exitdir),f))
15843 {
15844 return qe_invalid;
15845 }
15846
15847
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15848 {
15849
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15850 {
15851 return qe_invalid;
15852 }
15853
15854 24896 }
15855
15856
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15857 {
15858 if(!p_getc(&padding,f))
15859 {
15860 return qe_invalid;
15861 }
15862 }
15863
15864
2/2
✓ Branch 0 taken 11788560 times.
✓ Branch 1 taken 1178856 times.
12967416 for(int32_t k=0; k<10; k++)
15865 {
15866
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15867 {
15868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15869 {
15870 return qe_invalid;
15871 }
15872
15873 221760 temp_mapscr->enemy[k]=tempbyte;
15874
15875 // 76 is the highest enemy id possible to set in 1.90. Anything higher must have come
15876 // from corrupting when 1.90 saved the quest.
15877 // https://discord.com/channels/876899628556091432/1287580827164737658
15878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if (Header->zelda_version <= 0x190)
15879 {
15880
1/2
✓ Branch 0 taken 221760 times.
✗ Branch 1 not taken.
221760 if (temp_mapscr->enemy[k] > 76)
15881 {
15882 temp_mapscr->enemy[k] = 0;
15883 }
15884 221760 }
15885 221760 }
15886 else
15887 {
15888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11566800 times.
11566800 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15889 {
15890 return qe_invalid;
15891 }
15892 }
15893
15894
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15895 {
15896 //using enumerations here is dangerous
15897 //very easy to break old quests -DD
15898
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15899 {
15900 1342 temp_mapscr->enemy[k]+=5;
15901 1342 }
15902
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15903 {
15904 94 temp_mapscr->enemy[k]+=1;
15905 94 }
15906 221760 }
15907
15908
2/2
✓ Branch 0 taken 6503520 times.
✓ Branch 1 taken 5285040 times.
11788560 if(version < 9)
15909 {
15910
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15911 {
15912 275905 temp_mapscr->enemy[k]+=10;
15913 275905 }
15914 5285040 }
15915 //don't read in any invalid data
15916
2/2
✓ Branch 0 taken 11788110 times.
✓ Branch 1 taken 450 times.
11788560 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15917 {
15918 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15919 450 temp_mapscr->enemy[k] = 0;
15920 450 }
15921 11788560 }
15922
15923
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->pattern),f))
15924 {
15925 return qe_invalid;
15926 }
15927
15928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15929 {
15930 return qe_invalid;
15931 }
15932
15933
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15934 {
15935
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15936 {
15937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15938 {
15939 return qe_invalid;
15940 }
15941 1951056 }
15942 650352 }
15943 else
15944 {
15945 528504 temp_mapscr->sidewarptype[1]=0;
15946 528504 temp_mapscr->sidewarptype[2]=0;
15947 528504 temp_mapscr->sidewarptype[3]=0;
15948 }
15949
15950
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15951 {
15952
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15953 {
15954 return qe_invalid;
15955 }
15956 650352 }
15957 else
15958 {
15959 528504 temp_mapscr->sidewarpoverlayflags=0;
15960 }
15961
15962
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15963 {
15964 return qe_invalid;
15965 }
15966
15967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15968 {
15969 return qe_invalid;
15970 }
15971
15972
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
15973 {
15974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->path[k]),f))
15975 {
15976 return qe_invalid;
15977 }
15978 4715424 }
15979
15980
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15981 {
15982 return qe_invalid;
15983 }
15984
15985
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15986 {
15987
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 1951056 times.
2601408 for(int32_t i=1; i<4; i++)
15988 {
15989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15990 {
15991 return qe_invalid;
15992 }
15993 1951056 }
15994 650352 }
15995 else
15996 {
15997 528504 temp_mapscr->sidewarpscr[1]=0;
15998 528504 temp_mapscr->sidewarpscr[2]=0;
15999 528504 temp_mapscr->sidewarpscr[3]=0;
16000 }
16001
16002
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
16003 {
16004
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
16005 {
16006 return qe_invalid;
16007 }
16008
16009 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16010
16011
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16012 {
16013 for(int32_t i=1; i<4; i++)
16014 {
16015 if(!p_getc(&(tempbyte),f))
16016 {
16017 return qe_invalid;
16018 }
16019
16020 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16021 }
16022 }
16023 else
16024 {
16025 528504 temp_mapscr->sidewarpdmap[1]=0;
16026 528504 temp_mapscr->sidewarpdmap[2]=0;
16027 528504 temp_mapscr->sidewarpdmap[3]=0;
16028 }
16029 528504 }
16030 else
16031 {
16032
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
16033 {
16034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16035 {
16036 return qe_invalid;
16037 }
16038 2601408 }
16039 }
16040
16041
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16042 {
16043
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16044 {
16045 return qe_invalid;
16046 }
16047 650352 }
16048 528504 else temp_mapscr->sidewarpindex = 0;
16049
16050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_igetw(&(temp_mapscr->undercombo),f))
16051 {
16052 return qe_invalid;
16053 }
16054
16055 1178856 byte old_combo_page = 0;
16056
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
16057 {
16058
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_page, f))
16059 {
16060 return qe_invalid;
16061 }
16062
16063
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 24624 times.
24896 if (!should_skip)
16064 {
16065 24624 old_combo_pages[scrind] = old_combo_page;
16066 24624 }
16067 24896 }
16068
16069
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16070 {
16071 return qe_invalid;
16072 }
16073
16074
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_igetw(&(temp_mapscr->catchall),f))
16075 {
16076 return qe_invalid;
16077 }
16078
16079
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags),f))
16080 {
16081 return qe_invalid;
16082 }
16083
16084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags2),f))
16085 {
16086 return qe_invalid;
16087 }
16088
16089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags3),f))
16090 {
16091 return qe_invalid;
16092 }
16093
16094
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16095 //if (version>2)
16096 {
16097
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags4),f))
16098 {
16099 return qe_invalid;
16100 }
16101 650352 }
16102
16103
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16104 {
16105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags5),f))
16106 {
16107 return qe_invalid;
16108 }
16109
16110
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16111 return qe_invalid;
16112 650352 temp_mapscr->noreset = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED;
16113
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16114 return qe_invalid;
16115 1300704 temp_mapscr->nocarry = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED |
16116 650352 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16117
16118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(temp_mapscr->flags5&32)
16119 {
16120 temp_mapscr->flags5 &= ~32;
16121 temp_mapscr->noreset |= 48;
16122 }
16123
16124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(version<8)
16125 {
16126 if(temp_mapscr->noreset&1)
16127 {
16128 temp_mapscr->noreset|=8192;
16129 }
16130
16131 if(temp_mapscr->nocarry&1)
16132 {
16133 temp_mapscr->nocarry|=8192;
16134 temp_mapscr->nocarry&=~1;
16135 }
16136 }
16137 650352 }
16138 else
16139 {
16140 528504 temp_mapscr->flags5 = 0;
16141 528504 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
16142 528504 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
16143 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16144 }
16145
16146
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16147 {
16148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags6),f))
16149 {
16150 return qe_invalid;
16151 }
16152 650352 }
16153
16154
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>5)
16155 {
16156
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags7),f))
16157 {
16158 return qe_invalid;
16159 }
16160
16161
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags8),f))
16162 {
16163 return qe_invalid;
16164 }
16165
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags9),f))
16167 {
16168 return qe_invalid;
16169 }
16170
16171
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags10),f))
16172 {
16173 return qe_invalid;
16174 }
16175
16176
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->csensitive),f))
16177 {
16178 return qe_invalid;
16179 }
16180 650352 }
16181 else
16182 {
16183 528504 temp_mapscr->csensitive=1;
16184 }
16185
16186
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<14) // August 2007: screen SFX added
16187 {
16188
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16189 {
16190 994 temp_mapscr->bosssfx=
16191
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16192 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16193 WAV_ROAR;
16194 994 }
16195
16196
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16197 {
16198 170 temp_mapscr->oceansfx=WAV_SEA;
16199 170 }
16200
16201 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16202 ? 0 : WAV_SECRET;
16203
16204 528504 temp_mapscr->flags3 &= ~66; //64|2
16205 528504 temp_mapscr->flags2 &= ~32;
16206 528504 temp_mapscr->flags &= ~136; // 128|8
16207 528504 }
16208 else
16209 {
16210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->oceansfx),f))
16211 {
16212 return qe_invalid;
16213 }
16214
16215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->bosssfx),f))
16216 {
16217 return qe_invalid;
16218 }
16219
16220
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->secretsfx),f))
16221 {
16222 return qe_invalid;
16223 }
16224 }
16225
16226
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<15) // October 2007: another SFX
16227 {
16228 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16229 528504 }
16230 else
16231 {
16232
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16233 {
16234 return qe_invalid;
16235 }
16236 }
16237
16238
16239
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16240 {
16241
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16242 {
16243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16244 {
16245 return qe_invalid;
16246 }
16247 6940080 }
16248
16249
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 6940080 times.
8096760 for(int32_t k=0; k<6; k++)
16250 {
16251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16252 {
16253 return qe_invalid;
16254 }
16255 6940080 }
16256 1156680 }
16257
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16258 {
16259 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16260 {
16261 return qe_invalid;
16262 }
16263
16264 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16265 {
16266 return qe_invalid;
16267 }
16268
16269 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16270 {
16271 return qe_invalid;
16272 }
16273
16274 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16275
16276 {
16277 return qe_invalid;
16278 }
16279 }
16280
16281
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>149))
16282 {
16283
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16284 {
16285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16286 {
16287 return qe_invalid;
16288 }
16289 16320 }
16290
16291
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16292 {
16293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16294 {
16295 return qe_invalid;
16296 }
16297 16320 }
16298
16299
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16300 {
16301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16302 {
16303 return qe_invalid;
16304 }
16305 16320 }
16306
16307
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16308 {
16309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16310 {
16311 return qe_invalid;
16312 }
16313 16320 }
16314
16315
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16316 {
16317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16318 {
16319 return qe_invalid;
16320 }
16321 16320 }
16322
16323
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16324 {
16325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16326 {
16327 return qe_invalid;
16328 }
16329 16320 }
16330 2720 }
16331
16332
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16333 {
16334
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16335 {
16336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16337 {
16338 return qe_invalid;
16339 }
16340 6940080 }
16341 1156680 }
16342
16343
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16344 {
16345
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 if((Header->zelda_version == 0x192)&&(Header->build>153))
16346 {
16347
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16348 {
16349 return qe_invalid;
16350 }
16351 2720 }
16352
16353
1/2
✓ Branch 0 taken 1156680 times.
✗ Branch 1 not taken.
1156680 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16354 {
16355 return qe_invalid;
16356 }
16357 1156680 }
16358
16359
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16360 {
16361 22176 extras=15;
16362 22176 }
16363
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16364 {
16365 extras=11;
16366 }
16367
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16368 {
16369 extras=32;
16370 }
16371
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16372 {
16373 extras=64;
16374 }
16375
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 else if(Header->zelda_version < 0x193)
16376 {
16377 2720 extras=62;
16378 2720 }
16379 else
16380
16381 {
16382 1153960 extras=0;
16383 }
16384
16385
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1178856 times.
1680136 for(int32_t k=0; k<extras; k++)
16386 {
16387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16388 {
16389 return qe_invalid;
16390 }
16391 501280 }
16392
16393
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16394 //if (version>3)
16395 {
16396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->nextmap),f))
16397 {
16398 return qe_invalid;
16399 }
16400
16401
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->nextscr),f))
16402 {
16403 return qe_invalid;
16404 }
16405 650352 }
16406 else
16407 {
16408 528504 temp_mapscr->nextmap=0;
16409 528504 temp_mapscr->nextscr=0;
16410 }
16411
16412
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16413 {
16414 22176 secretcombos=20;
16415 22176 }
16416
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16417 {
16418 secretcombos=256;
16419 }
16420 else
16421 {
16422 1156680 secretcombos=128;
16423 }
16424
16425
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16426 {
16427
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16428 {
16429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16430 {
16431 return qe_invalid;
16432 }
16433
16434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16435 {
16436 443520 temp_mapscr->secretcombo[k]=tempbyte;
16437 443520 }
16438 443520 }
16439 22176 }
16440 else
16441 {
16442
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16443 {
16444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16445 {
16446 return qe_invalid;
16447 }
16448
16449 148055040 }
16450 }
16451
16452
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16453 {
16454
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16455 {
16456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16457 {
16458 return qe_invalid;
16459 }
16460 148055040 }
16461
16462
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16463 {
16464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16465 {
16466 return qe_invalid;
16467 }
16468 148055040 }
16469 1156680 }
16470
16471
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16472 {
16473 if(!p_getc(&padding,f))
16474 {
16475 return qe_invalid;
16476 }
16477 }
16478
16479
2/2
✓ Branch 0 taken 207478656 times.
✓ Branch 1 taken 1178856 times.
208657512 for(int32_t k=0; k<176; k++)
16480 {
16481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207478656 times.
207478656 if(!p_igetw(&(temp_mapscr->data[k]),f))
16482 {
16483 return qe_invalid;
16484 }
16485 207478656 }
16486
16487
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16488 {
16489 if(!p_getc(&padding,f))
16490 {
16491 return qe_invalid;
16492 }
16493
16494 if(!p_getc(&padding,f))
16495 {
16496 return qe_invalid;
16497 }
16498 }
16499
16500
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16501 {
16502
2/2
✓ Branch 0 taken 203575680 times.
✓ Branch 1 taken 1156680 times.
204732360 for(int32_t k=0; k<176; k++)
16503 {
16504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16505 {
16506 return qe_invalid;
16507 }
16508
16509
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 203096960 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
203575680 if((Header->zelda_version == 0x192)&&(Header->build<24))
16510 {
16511 if(!p_getc(&tempbyte,f))
16512 {
16513 return qe_invalid;
16514 }
16515
16516 if(!p_getc(&tempbyte,f))
16517 {
16518 return qe_invalid;
16519 }
16520
16521 if(!p_getc(&tempbyte,f))
16522 {
16523 return qe_invalid;
16524 }
16525 }
16526 203575680 }
16527 1156680 }
16528
16529
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16530 {
16531
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 203575680 times.
204732360 for(int32_t k=0; k<176; k++)
16532 {
16533
16534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->cset[k]),f))
16535 {
16536 return qe_invalid;
16537 }
16538 203575680 }
16539 1156680 }
16540
16541
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16542 {
16543 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16544 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_page<<8);
16545 22176 }
16546
16547
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16548 {
16549 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16550 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16551 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16552 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16553 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16554 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16555 22176 }
16556
16557
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16558 {
16559
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16560 {
16561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16562 {
16563 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16564 {
16565 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16566 }
16567 }
16568 else
16569 {
16570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16571 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16572 {
16573 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16574 3902976 }
16575
16576 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16577 }
16578
16579 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_page<<8);
16580 3902976 }
16581 22176 }
16582
16583 /*if(version>12)
16584 {
16585 if(!p_getc(&(temp_mapscr->scrWidth),f))
16586 {
16587 return qe_invalid;
16588 }
16589 if(!p_getc(&(temp_mapscr->scrHeight),f))
16590 {
16591 return qe_invalid;
16592 }
16593 }*/
16594
16595
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>4)
16596 {
16597
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16598 {
16599 return qe_invalid;
16600 }
16601 650352 }
16602 else
16603 {
16604 528504 temp_mapscr->screen_midi = -1;
16605 }
16606
16607
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>=17)
16608 {
16609
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->lens_layer),f))
16610 {
16611 return qe_invalid;
16612 }
16613 650352 }
16614 else
16615 {
16616 528504 temp_mapscr->lens_layer = llNORMAL;
16617 }
16618
16619
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version>6)
16620 {
16621 dword bits;
16622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_igetl(&bits,f))
16623 {
16624 return qe_invalid;
16625 }
16626
16627 int32_t m;
16628 float tempfloat;
16629 word tempw;
16630 650352 temp_mapscr->ffcCountMarkDirty();
16631 650352 temp_mapscr->ffcs.clear();
16632 650352 temp_mapscr->resizeFFC(std::bit_width(bits));
16633
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 20811264 times.
21461616 for(m=0; m<32; m++)
16634 {
16635
2/2
✓ Branch 0 taken 20536512 times.
✓ Branch 1 taken 274752 times.
20811264 if((bits>>m)&1)
16636 {
16637 274752 ffcdata& tempffc = temp_mapscr->ffcs[m];
16638
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetw(&tempw,f))
16639 {
16640 return qe_invalid;
16641 }
16642 274752 tempffc.data = tempw;
16643
16644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.cset),f))
16645 {
16646 return qe_invalid;
16647 }
16648
16649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.delay),f))
16650 {
16651 return qe_invalid;
16652 }
16653
16654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version < 9)
16655 {
16656 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16657 {
16658 return qe_invalid;
16659 }
16660
16661 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16662
16663 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16664 {
16665 return qe_invalid;
16666 }
16667
16668 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16669
16670 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16671 {
16672 return qe_invalid;
16673 }
16674
16675 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16676
16677 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16678 {
16679 return qe_invalid;
16680 }
16681
16682 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16683
16684 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16685 {
16686 return qe_invalid;
16687 }
16688
16689 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16690
16691 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16692 {
16693 return qe_invalid;
16694 }
16695
16696 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16697 }
16698 else
16699 {
16700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.x),f))
16701 {
16702 return qe_invalid;
16703 }
16704
16705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.y),f))
16706 {
16707 return qe_invalid;
16708 }
16709
16710
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetzf(&(tempffc.vx),f))
16711 {
16712 return qe_invalid;
16713 }
16714
16715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.vy),f))
16716 {
16717 return qe_invalid;
16718 }
16719
16720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ax),f))
16721 {
16722 return qe_invalid;
16723 }
16724
16725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ay),f))
16726 {
16727 return qe_invalid;
16728 }
16729 }
16730
16731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.link),f))
16732 {
16733 return qe_invalid;
16734 }
16735
16736
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>7)
16737 {
16738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16739 {
16740 return qe_invalid;
16741 }
16742
16743 274752 tempffc.hit_width = (tempbyte&0x3F)+1;
16744 274752 tempffc.txsz = (tempbyte>>6)+1;
16745
16746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16747 {
16748 return qe_invalid;
16749 }
16750
16751 274752 tempffc.hit_height = (tempbyte&0x3F)+1;
16752 274752 tempffc.tysz = (tempbyte>>6)+1;
16753
16754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.flags),f))
16755 {
16756 return qe_invalid;
16757 }
16758 274752 }
16759 else
16760 {
16761 tempffc.hit_width=16;
16762 tempffc.hit_height=16;
16763 tempffc.txsz=1;
16764 tempffc.tysz=1;
16765 tempffc.flags=ffc_none;
16766 }
16767
16768 274752 tempffc.updateSolid();
16769
16770
16771
4/6
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268748 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 268748 times.
274752 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16772 {
16773 tempffc.flags|=ffc_ignoreholdup;
16774 }
16775
16776
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>9)
16777 {
16778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.script),f))
16779 {
16780 return qe_invalid;
16781 }
16782 274752 }
16783 else
16784 {
16785 tempffc.script=0;
16786 }
16787
16788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version>10)
16789 {
16790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[0]),f))
16791 {
16792 return qe_invalid;
16793 }
16794
16795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[1]),f))
16796 {
16797 return qe_invalid;
16798 }
16799
16800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[2]),f))
16801 {
16802 return qe_invalid;
16803 }
16804
16805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[3]),f))
16806 {
16807 return qe_invalid;
16808 }
16809
16810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[4]),f))
16811 {
16812 return qe_invalid;
16813 }
16814
16815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[5]),f))
16816 {
16817 return qe_invalid;
16818 }
16819
16820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[6]),f))
16821 {
16822 return qe_invalid;
16823 }
16824
16825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[7]),f))
16826 {
16827 return qe_invalid;
16828 }
16829
16830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16831 {
16832 return qe_invalid;
16833 }
16834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16835 {
16836 return qe_invalid;
16837 }
16838 274752 }
16839
16840
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16841 {
16842 tempffc.script = 0;
16843 for(int q = 0; q < 8; ++q)
16844 tempffc.initd[q] = 0;
16845 }
16846
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version <= 11)
16847 {
16848 fixffcs=true;
16849 }
16850 274752 }
16851 20811264 }
16852
16853 650352 temp_mapscr->shrinkToFitFFCs();
16854 650352 }
16855
16856
16857 //add in the new whistle flags
16858
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version<13)
16859 {
16860
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16861 {
16862 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16863 124 }
16864 528504 }
16865
16866 //2.55 starts here
16867
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 19 && Header->zelda_version > 0x253 )
16868 {
16869 // mapscr fields that were never used, so are now removed:
16870 // int32_t npcstrings[10];
16871 // int16_t new_items[10];
16872 // int16_t new_item_x[10];
16873 // int16_t new_item_y[10];
16874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16875 {
16876 return qe_invalid;
16877 }
16878 34408 }
16879
16880
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 20 && Header->zelda_version > 0x253 )
16881 {
16882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16883 {
16884 return qe_invalid;
16885 }
16886
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16887 {
16888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16889 {
16890 return qe_invalid;
16891 }
16892 275264 }
16893 34408 }
16894
2/2
✓ Branch 0 taken 1144448 times.
✓ Branch 1 taken 34408 times.
1178856 if ( version < 20 )
16895 {
16896 1144448 temp_mapscr->script = 0;
16897
2/2
✓ Branch 0 taken 9155584 times.
✓ Branch 1 taken 1144448 times.
10300032 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16898 1144448 }
16899
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 21 && Header->zelda_version > 0x253 )
16900 {
16901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16902 {
16903 return qe_invalid;
16904 }
16905 34408 }
16906
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 21 )
16907 {
16908 1144448 temp_mapscr->preloadscript = 0;
16909 1144448 }
16910
16911
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16912 {
16913
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16914 {
16915 return qe_invalid;
16916 }
16917
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16918 {
16919 return qe_invalid;
16920 }
16921 34408 }
16922
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 22 )
16923 {
16924 1144448 temp_mapscr->hidelayers = 0;
16925 1144448 temp_mapscr->hidescriptlayers = 0;
16926 1144448 }
16927
16928 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16929 //May be any version before 2.11. -Z
16930 /* --not the roar, the HIT SFX
16931 if ( Header->zelda_version <= 0x210 )
16932 {
16933 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16934 {
16935 temp_mapscr->bosssfx = WAV_ROAR;
16936 }
16937 }
16938 */
16939
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16940 {
16941
1/2
✓ Branch 0 taken 4715424 times.
✗ Branch 1 not taken.
4715424 if(temp_mapscr->door[k] == dNONE)
16942 temp_mapscr->door[k] = dWALL;
16943 4715424 }
16944
16945 1178856 return 0;
16946 1178856 }
16947 1385576 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16948 {
16949
2/2
✓ Branch 0 taken 1178856 times.
✓ Branch 1 taken 206720 times.
1385576 if(version < 23)
16950 {
16951 1178856 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(ret) return ret;
16953 1178856 }
16954 else
16955 {
16956
1/2
✓ Branch 0 taken 206720 times.
✗ Branch 1 not taken.
206720 if(!p_getc(&(temp_mapscr->valid),f))
16957 return qe_invalid;
16958
2/2
✓ Branch 0 taken 106424 times.
✓ Branch 1 taken 100296 times.
206720 if(!(temp_mapscr->valid & mVALID))
16959 {
16960 100296 int map = scrind/MAPSCRS;
16961 100296 int screen = scrind%MAPSCRS;
16962
4/6
✓ Branch 0 taken 93194 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 93194 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 93194 times.
100296 if(version > 25 && scrind > -1 && map < map_infos.size())
16963 {
16964 93194 auto const& mapinf = map_infos[map];
16965 //Empty screen, apply defaults
16966
2/2
✓ Branch 0 taken 559164 times.
✓ Branch 1 taken 93194 times.
652358 for(int q = 0; q < 6; ++q)
16967 {
16968 559164 auto layermap = mapinf.autolayers[q];
16969 559164 temp_mapscr->layermap[q] = layermap;
16970
2/2
✓ Branch 0 taken 543627 times.
✓ Branch 1 taken 15537 times.
559164 if(layermap)
16971 15537 temp_mapscr->layerscreen[q] = screen;
16972 559164 }
16973 93194 temp_mapscr->color = mapinf.autopalette;
16974 93194 }
16975 100296 return 0;
16976 }
16977 uint32_t scr_has_flags;
16978
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_igetl(&scr_has_flags,f))
16979 return qe_invalid;
16980
16981
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 95966 times.
106424 if(scr_has_flags & SCRHAS_ROOMDATA)
16982 {
16983
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_getc(&(temp_mapscr->guy),f))
16984 return qe_invalid;
16985
2/2
✓ Branch 0 taken 95846 times.
✓ Branch 1 taken 120 times.
95966 if(version > 26)
16986 {
16987
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_igetl(&(temp_mapscr->guytile),f))
16988 return qe_invalid;
16989
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_getc(&(temp_mapscr->guycs),f))
16990 return qe_invalid;
16991
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_igetw(&(temp_mapscr->roomflags),f))
16992 return qe_invalid;
16993 95846 }
16994 else
16995 {
16996 120 temp_mapscr->guytile = -1; //signal to use default guy values
16997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16999 }
17000
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_igetw(&(temp_mapscr->str),f))
17001 return qe_invalid;
17002
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_getc(&(temp_mapscr->room),f))
17003 return qe_invalid;
17004
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_igetw(&(temp_mapscr->catchall),f))
17005 return qe_invalid;
17006 95966 }
17007
2/2
✓ Branch 0 taken 104052 times.
✓ Branch 1 taken 2372 times.
106424 if(scr_has_flags & SCRHAS_ITEM)
17008 {
17009
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->item),f))
17010 return qe_invalid;
17011
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->hasitem),f))
17012 return qe_invalid;
17013
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->itemx),f))
17014 return qe_invalid;
17015
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->itemy),f))
17016 return qe_invalid;
17017 2372 }
17018
2/2
✓ Branch 0 taken 95745 times.
✓ Branch 1 taken 10679 times.
106424 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17019 {
17020
1/2
✓ Branch 0 taken 10679 times.
✗ Branch 1 not taken.
10679 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17021 return qe_invalid;
17022 10679 }
17023
2/2
✓ Branch 0 taken 103938 times.
✓ Branch 1 taken 2486 times.
106424 if(scr_has_flags & SCRHAS_TWARP)
17024 {
17025
2/2
✓ Branch 0 taken 9944 times.
✓ Branch 1 taken 2486 times.
12430 for(int32_t i=0; i<4; i++)
17026 {
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9944 times.
9944 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17028 return qe_invalid;
17029 9944 }
17030
2/2
✓ Branch 0 taken 9944 times.
✓ Branch 1 taken 2486 times.
12430 for(int32_t i=0; i<4; i++)
17031 {
17032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9944 times.
9944 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17033 return qe_invalid;
17034 9944 }
17035
2/2
✓ Branch 0 taken 9944 times.
✓ Branch 1 taken 2486 times.
12430 for(int32_t i=0; i<4; i++)
17036 {
17037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9944 times.
9944 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17038 return qe_invalid;
17039 9944 }
17040
1/2
✓ Branch 0 taken 2486 times.
✗ Branch 1 not taken.
2486 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17041 return qe_invalid;
17042 2486 }
17043
2/2
✓ Branch 0 taken 97756 times.
✓ Branch 1 taken 8668 times.
106424 if(scr_has_flags & SCRHAS_SWARP)
17044 {
17045
2/2
✓ Branch 0 taken 34672 times.
✓ Branch 1 taken 8668 times.
43340 for(int32_t i=0; i<4; i++)
17046 {
17047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34672 times.
34672 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17048 return qe_invalid;
17049 34672 }
17050
2/2
✓ Branch 0 taken 34672 times.
✓ Branch 1 taken 8668 times.
43340 for(int32_t i=0; i<4; i++)
17051 {
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34672 times.
34672 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17053 return qe_invalid;
17054 34672 }
17055
2/2
✓ Branch 0 taken 34672 times.
✓ Branch 1 taken 8668 times.
43340 for(int32_t i=0; i<4; i++)
17056 {
17057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34672 times.
34672 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17058 return qe_invalid;
17059 34672 }
17060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8668 times.
8668 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17061 return qe_invalid;
17062
1/2
✓ Branch 0 taken 8668 times.
✗ Branch 1 not taken.
8668 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17063 return qe_invalid;
17064 8668 }
17065
2/2
✓ Branch 0 taken 99733 times.
✓ Branch 1 taken 6691 times.
106424 if(scr_has_flags & SCRHAS_WARPRET)
17066 {
17067
2/2
✓ Branch 0 taken 26764 times.
✓ Branch 1 taken 6691 times.
33455 for(int32_t i=0; i<4; i++)
17068 {
17069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26764 times.
26764 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17070 return qe_invalid;
17071 26764 }
17072
2/2
✓ Branch 0 taken 26764 times.
✓ Branch 1 taken 6691 times.
33455 for(int32_t i=0; i<4; i++)
17073 {
17074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26764 times.
26764 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17075 return qe_invalid;
17076 26764 }
17077
1/2
✓ Branch 0 taken 6691 times.
✗ Branch 1 not taken.
6691 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17078 return qe_invalid;
17079
1/2
✓ Branch 0 taken 6691 times.
✗ Branch 1 not taken.
6691 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17080 return qe_invalid;
17081 6691 }
17082
2/2
✓ Branch 0 taken 92896 times.
✓ Branch 1 taken 13528 times.
106424 if(scr_has_flags & SCRHAS_LAYERS)
17083 {
17084
2/2
✓ Branch 0 taken 81168 times.
✓ Branch 1 taken 13528 times.
94696 for(int32_t k=0; k<6; k++)
17085 {
17086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81168 times.
81168 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17087 return qe_invalid;
17088 81168 }
17089
2/2
✓ Branch 0 taken 81168 times.
✓ Branch 1 taken 13528 times.
94696 for(int32_t k=0; k<6; k++)
17090 {
17091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81168 times.
81168 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17092 return qe_invalid;
17093 81168 }
17094
2/2
✓ Branch 0 taken 81168 times.
✓ Branch 1 taken 13528 times.
94696 for(int32_t k=0; k<6; k++)
17095 {
17096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81168 times.
81168 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17097 return qe_invalid;
17098 81168 }
17099
1/2
✓ Branch 0 taken 13528 times.
✗ Branch 1 not taken.
13528 if(!p_getc(&(temp_mapscr->hidelayers),f))
17100 return qe_invalid;
17101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13528 times.
13528 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17102 return qe_invalid;
17103 13528 }
17104
2/2
✓ Branch 0 taken 106320 times.
✓ Branch 1 taken 104 times.
106424 if(scr_has_flags & SCRHAS_MAZE)
17105 {
17106
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17107 {
17108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
17109 return qe_invalid;
17110 416 }
17111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
17112 return qe_invalid;
17113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
17114 {
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
17116 return qe_invalid;
17117 104 }
17118 104 }
17119
2/2
✓ Branch 0 taken 77498 times.
✓ Branch 1 taken 28926 times.
106424 if(scr_has_flags & SCRHAS_D_S_U)
17120 {
17121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77498 times.
77498 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17122 return qe_invalid;
17123
2/2
✓ Branch 0 taken 309992 times.
✓ Branch 1 taken 77498 times.
387490 for(int32_t k=0; k<4; k++)
17124 {
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309992 times.
309992 if(!p_getc(&(temp_mapscr->door[k]),f))
17126 return qe_invalid;
17127
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 309632 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
309992 if(version < 29 && temp_mapscr->door[k] == dNONE)
17128 temp_mapscr->door[k] = dWALL;
17129 309992 }
17130
17131
1/2
✓ Branch 0 taken 77498 times.
✗ Branch 1 not taken.
77498 if(!p_getc(&(temp_mapscr->stairx),f))
17132 return qe_invalid;
17133
17134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77498 times.
77498 if(!p_getc(&(temp_mapscr->stairy),f))
17135 return qe_invalid;
17136
1/2
✓ Branch 0 taken 77498 times.
✗ Branch 1 not taken.
77498 if(!p_igetw(&(temp_mapscr->undercombo),f))
17137 return qe_invalid;
17138
1/2
✓ Branch 0 taken 77498 times.
✗ Branch 1 not taken.
77498 if(!p_getc(&(temp_mapscr->undercset),f))
17139 return qe_invalid;
17140 77498 }
17141
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 18438 times.
28926 else if(version < 29)
17142 {
17143
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17144 41952 temp_mapscr->door[k] = dWALL;
17145 10488 }
17146
2/2
✓ Branch 0 taken 99921 times.
✓ Branch 1 taken 6503 times.
106424 if(scr_has_flags & SCRHAS_FLAGS)
17147 {
17148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6503 times.
6503 if(!p_getc(&(temp_mapscr->flags),f))
17149 return qe_invalid;
17150
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags2),f))
17151 return qe_invalid;
17152
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags3),f))
17153 return qe_invalid;
17154
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags4),f))
17155 return qe_invalid;
17156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6503 times.
6503 if(!p_getc(&(temp_mapscr->flags5),f))
17157 return qe_invalid;
17158
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags6),f))
17159 return qe_invalid;
17160
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags7),f))
17161 return qe_invalid;
17162
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags8),f))
17163 return qe_invalid;
17164
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags9),f))
17165 return qe_invalid;
17166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6503 times.
6503 if(!p_getc(&(temp_mapscr->flags10),f))
17167 return qe_invalid;
17168
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags11),f))
17169 return qe_invalid;
17170 6503 }
17171
2/2
✓ Branch 0 taken 101133 times.
✓ Branch 1 taken 5291 times.
106424 if(scr_has_flags & SCRHAS_ENEMY)
17172 {
17173
2/2
✓ Branch 0 taken 52910 times.
✓ Branch 1 taken 5291 times.
58201 for(int32_t k=0; k<10; k++)
17174 {
17175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52910 times.
52910 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17176 return qe_invalid;
17177
1/2
✓ Branch 0 taken 52910 times.
✗ Branch 1 not taken.
52910 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17178 temp_mapscr->enemy[k] = 0;
17179 52910 }
17180
1/2
✓ Branch 0 taken 5291 times.
✗ Branch 1 not taken.
5291 if(!p_getc(&(temp_mapscr->pattern),f))
17181 return qe_invalid;
17182 5291 }
17183
2/2
✓ Branch 0 taken 37024 times.
✓ Branch 1 taken 69400 times.
106424 if(scr_has_flags & SCRHAS_CARRY)
17184 {
17185
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 36666 times.
37024 if(version < 34)
17186 {
17187 word tmpw;
17188
1/2
✓ Branch 0 taken 358 times.
✗ Branch 1 not taken.
358 if(!p_igetw(&tmpw,f))
17189 return qe_invalid;
17190 358 temp_mapscr->noreset = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED;
17191
1/2
✓ Branch 0 taken 358 times.
✗ Branch 1 not taken.
358 if(!p_igetw(&tmpw,f))
17192 return qe_invalid;
17193 716 temp_mapscr->nocarry = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED |
17194 358 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17195 358 }
17196 else
17197 {
17198
1/2
✓ Branch 0 taken 36666 times.
✗ Branch 1 not taken.
36666 if(!p_igetl(&(temp_mapscr->noreset),f))
17199 return qe_invalid;
17200
1/2
✓ Branch 0 taken 36666 times.
✗ Branch 1 not taken.
36666 if(!p_igetl(&(temp_mapscr->nocarry),f))
17201 return qe_invalid;
17202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36666 times.
36666 if(!p_igetl(&(temp_mapscr->exstate_reset),f))
17203 return qe_invalid;
17204
1/2
✓ Branch 0 taken 36666 times.
✗ Branch 1 not taken.
36666 if(!p_igetl(&(temp_mapscr->exstate_carry),f))
17205 return qe_invalid;
17206 }
17207
1/2
✓ Branch 0 taken 37024 times.
✗ Branch 1 not taken.
37024 if(!p_getc(&(temp_mapscr->nextmap),f))
17208 return qe_invalid;
17209
1/2
✓ Branch 0 taken 37024 times.
✗ Branch 1 not taken.
37024 if(!p_getc(&(temp_mapscr->nextscr),f))
17210 return qe_invalid;
17211 37024 }
17212 else
17213 {
17214
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 69386 times.
69400 if(version < 34)
17215 {
17216 69386 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
17217 69386 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
17218 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17219 69386 }
17220 }
17221
2/2
✓ Branch 0 taken 105827 times.
✓ Branch 1 taken 597 times.
106424 if(scr_has_flags & SCRHAS_SCRIPT)
17222 {
17223
1/2
✓ Branch 0 taken 597 times.
✗ Branch 1 not taken.
597 if(!p_igetw(&(temp_mapscr->script),f))
17224 return qe_invalid;
17225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 597 times.
597 if(!p_getc(&(temp_mapscr->preloadscript),f))
17226 return qe_invalid;
17227
2/2
✓ Branch 0 taken 4776 times.
✓ Branch 1 taken 597 times.
5373 for ( int32_t q = 0; q < 8; q++ )
17228 {
17229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4776 times.
4776 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17230 return qe_invalid;
17231 4776 }
17232 597 }
17233
2/2
✓ Branch 0 taken 74932 times.
✓ Branch 1 taken 31492 times.
106424 if(scr_has_flags & SCRHAS_SECRETS)
17234 {
17235
2/2
✓ Branch 0 taken 4030976 times.
✓ Branch 1 taken 31492 times.
4062468 for(int32_t k=0; k<128; k++)
17236 {
17237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4030976 times.
4030976 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17238 return qe_invalid;
17239 4030976 }
17240
2/2
✓ Branch 0 taken 4030976 times.
✓ Branch 1 taken 31492 times.
4062468 for(int32_t k=0; k<128; k++)
17241 {
17242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4030976 times.
4030976 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17243 return qe_invalid;
17244 4030976 }
17245
2/2
✓ Branch 0 taken 4030976 times.
✓ Branch 1 taken 31492 times.
4062468 for(int32_t k=0; k<128; k++)
17246 {
17247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4030976 times.
4030976 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17248 return qe_invalid;
17249 4030976 }
17250 31492 }
17251
2/2
✓ Branch 0 taken 40663 times.
✓ Branch 1 taken 65761 times.
106424 if(scr_has_flags & SCRHAS_COMBOFLAG)
17252 {
17253
2/2
✓ Branch 0 taken 11573936 times.
✓ Branch 1 taken 65761 times.
11639697 for(int32_t k=0; k<176; ++k)
17254 {
17255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11573936 times.
11573936 if(!p_igetw(&(temp_mapscr->data[k]),f))
17256 return qe_invalid;
17257 11573936 }
17258
2/2
✓ Branch 0 taken 11573936 times.
✓ Branch 1 taken 65761 times.
11639697 for(int32_t k=0; k<176; ++k)
17259 {
17260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11573936 times.
11573936 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17261 return qe_invalid;
17262 11573936 }
17263
2/2
✓ Branch 0 taken 11573936 times.
✓ Branch 1 taken 65761 times.
11639697 for(int32_t k=0; k<176; ++k)
17264 {
17265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11573936 times.
11573936 if(!p_getc(&(temp_mapscr->cset[k]),f))
17266 return qe_invalid;
17267 11573936 }
17268 65761 }
17269
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(scr_has_flags & SCRHAS_MISC)
17270 {
17271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106424 times.
106424 if(!p_igetw(&(temp_mapscr->color),f))
17272 return qe_invalid;
17273
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->csensitive),f))
17274 return qe_invalid;
17275
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->oceansfx),f))
17276 return qe_invalid;
17277
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->bosssfx),f))
17278 return qe_invalid;
17279
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->secretsfx),f))
17280 return qe_invalid;
17281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106424 times.
106424 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17282 return qe_invalid;
17283
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17284 return qe_invalid;
17285
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17286 return qe_invalid;
17287
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->lens_layer),f))
17288 return qe_invalid;
17289
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 95846 times.
106424 if(version > 27)
17290 {
17291
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_getc(&(temp_mapscr->lens_show),f))
17292 return qe_invalid;
17293
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_getc(&(temp_mapscr->lens_hide),f))
17294 return qe_invalid;
17295 95846 }
17296 106424 }
17297 else
17298 {
17299 temp_mapscr->screen_midi = -1;
17300 temp_mapscr->csensitive = 1;
17301 }
17302 //FFC
17303 106424 bool old_ff = version < 25;
17304 106424 dword bits = 0;
17305 106424 word numffc = 32;
17306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106424 times.
106424 if(old_ff)
17307 {
17308 if(!p_igetl(&bits,f))
17309 return qe_invalid;
17310 }
17311 else
17312 {
17313
2/4
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 106424 times.
106424 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17314 return qe_invalid;
17315 }
17316
17317 106424 temp_mapscr->ffcCountMarkDirty();
17318 106424 temp_mapscr->ffcs.clear();
17319 106424 temp_mapscr->resizeFFC(numffc);
17320
17321 byte tempbyte;
17322 word tempw;
17323
4/6
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 106260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 164 times.
✓ Branch 4 taken 164 times.
✗ Branch 5 not taken.
106424 static ffcdata nil_ffc;
17324
2/2
✓ Branch 0 taken 1982056 times.
✓ Branch 1 taken 106424 times.
2088480 for(word m = 0; m < numffc; ++m)
17325 {
17326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1982056 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1982056 if(old_ff && !(bits & (1<<m))) continue;
17327
17328
1/2
✓ Branch 0 taken 1982056 times.
✗ Branch 1 not taken.
1982056 ffcdata& tempffc = (m < MAXFFCS)
17329 1982056 ? temp_mapscr->ffcs[m]
17330 : nil_ffc; //sanity
17331
17332
1/2
✓ Branch 0 taken 1982056 times.
✗ Branch 1 not taken.
1982056 if(!p_igetw(&tempw,f))
17333 return qe_invalid;
17334
3/4
✓ Branch 0 taken 1982056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14633 times.
✓ Branch 3 taken 1967423 times.
1982056 if(!old_ff && !tempw) //empty ffc, nothing more to load
17335 1967423 continue;
17336 14633 tempffc.data = tempw;
17337
17338
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_getc(&(tempffc.cset),f))
17339 return qe_invalid;
17340
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetw(&(tempffc.delay),f))
17341 return qe_invalid;
17342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetzf(&(tempffc.x),f))
17343 return qe_invalid;
17344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetzf(&(tempffc.y),f))
17345 return qe_invalid;
17346
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetzf(&(tempffc.vx),f))
17347 return qe_invalid;
17348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetzf(&(tempffc.vy),f))
17349 return qe_invalid;
17350
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetzf(&(tempffc.ax),f))
17351 return qe_invalid;
17352
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetzf(&(tempffc.ay),f))
17353 return qe_invalid;
17354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_getc(&(tempffc.link),f))
17355 return qe_invalid;
17356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(version < 24)
17357 {
17358 if(!p_getc(&tempbyte,f))
17359 return qe_invalid;
17360 tempffc.hit_width = (tempbyte&0x3F)+1;
17361 tempffc.txsz = (tempbyte>>6)+1;
17362 if(!p_getc(&tempbyte,f))
17363 return qe_invalid;
17364 tempffc.hit_height = (tempbyte&0x3F)+1;
17365 tempffc.tysz = (tempbyte>>6)+1;
17366 }
17367 else
17368 {
17369
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetl(&(tempffc.hit_width),f))
17370 return qe_invalid;
17371
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetl(&(tempffc.hit_height),f))
17372 return qe_invalid;
17373
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_getc(&(tempffc.txsz),f))
17374 return qe_invalid;
17375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_getc(&(tempffc.tysz),f))
17376 return qe_invalid;
17377 }
17378
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetl(&(tempffc.flags),f))
17379 return qe_invalid;
17380 14633 tempffc.updateSolid();
17381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetw(&(tempffc.script),f))
17382 return qe_invalid;
17383
2/2
✓ Branch 0 taken 117064 times.
✓ Branch 1 taken 14633 times.
131697 for(auto q = 0; q < 8; ++q)
17384 {
17385
1/2
✓ Branch 0 taken 117064 times.
✗ Branch 1 not taken.
117064 if(!p_igetl(&(tempffc.initd[q]),f))
17386 return qe_invalid;
17387 117064 }
17388
2/2
✓ Branch 0 taken 8011 times.
✓ Branch 1 taken 6622 times.
14633 if(version < 33)
17389 {
17390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17391 return qe_invalid;
17392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17393 return qe_invalid;
17394 8011 }
17395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6622 times.
6622 else if(!p_getc(&(tempffc.layer),f))
17396 return qe_invalid;
17397
17398
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17399 {
17400 tempffc.script = 0;
17401 for(int q = 0; q < 8; ++q)
17402 tempffc.initd[q] = 0;
17403 }
17404 14633 }
17405 //END FFC
17406
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 67927 times.
106424 if(version > 29)
17407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67927 times.
67927 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17408 return qe_invalid;
17409
17410
4/4
✓ Branch 0 taken 33196 times.
✓ Branch 1 taken 73228 times.
✓ Branch 2 taken 33148 times.
✓ Branch 3 taken 48 times.
106424 if (version >= 35 && (temp_mapscr->flags10 & fSCREEN_GRAVITY))
17411 {
17412
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if (!p_igetzf(&temp_mapscr->screen_gravity, f))
17413 return qe_invalid;
17414
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if (!p_igetzf(&temp_mapscr->screen_terminal_v, f))
17415 return qe_invalid;
17416 48 }
17417 }
17418
17419 1285280 temp_mapscr->shrinkToFitFFCs();
17420
17421 1285280 return 0;
17422 1385576 }
17423
17424 481 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17425 {
17426
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17427 481 int32_t screen=0;
17428
17429 481 word version=0;
17430 dword dummy;
17431 int32_t screens_to_read;
17432
17433 481 mapscr temp_mapscr{};
17434 word temp_map_count;
17435 dword section_size;
17436
17437
5/6
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
481 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17438 {
17439 18 screens_to_read=MAPSCRS192b136;
17440 18 }
17441 else
17442 {
17443 463 screens_to_read=MAPSCRS;
17444 }
17445
17446
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 if(Header->zelda_version > 0x192)
17447 {
17448 //section version info
17449
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&version,f))
17450 {
17451 return qe_invalid;
17452 }
17453
17454 457 FFCore.quest_format[vMaps] = version;
17455
17456
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dummy,f))
17457 {
17458 return qe_invalid;
17459 }
17460
17461 //section size
17462
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&section_size,f))
17463 {
17464 return qe_invalid;
17465 }
17466
17467 //finally... section data
17468
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&temp_map_count,f))
17469 {
17470 return 5;
17471 }
17472 457 }
17473 else
17474 {
17475 24 temp_map_count=map_count;
17476 }
17477
17478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
481 if (temp_map_count > MAXMAPS)
17479 {
17480 return qe_invalid;
17481 }
17482
17483
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1 times.
481 if (!should_skip)
17484 {
17485 480 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17486 480 TheMaps.clear();
17487
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 TheMaps.resize(_mapsSize);
17488 480 old_combo_pages.clear();
17489
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 old_combo_pages.resize(_mapsSize);
17490 480 map_infos.clear();
17491
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 map_infos.resize(temp_map_count);
17492
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 153 times.
480 if(version >= 31)
17493 153 Regions = {};
17494 480 }
17495
17496
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 10326 times.
✓ Branch 2 taken 10326 times.
✓ Branch 3 taken 481 times.
10807 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17497 {
17498 10326 byte valid=1;
17499
2/2
✓ Branch 0 taken 1653 times.
✓ Branch 1 taken 8673 times.
10326 if(version > 22)
17500 {
17501
2/4
✓ Branch 0 taken 1653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1653 times.
✗ Branch 3 not taken.
1653 if(!p_getc(&valid,f))
17502 return qe_invalid;
17503 1653 }
17504
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 10193 times.
10326 if(valid)
17505 {
17506
2/2
✓ Branch 0 taken 8803 times.
✓ Branch 1 taken 1390 times.
10193 if (version > 25)
17507 {
17508 1390 auto& mapinf = map_infos[i];
17509
2/2
✓ Branch 0 taken 8340 times.
✓ Branch 1 taken 1390 times.
9730 for(int q = 0; q < 6; ++q)
17510 {
17511
2/4
✓ Branch 0 taken 8340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8340 times.
✗ Branch 3 not taken.
8340 if(!p_igetw(&mapinf.autolayers[q],f))
17512 return qe_invalid;
17513 8340 }
17514
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 926 times.
1390 if (version >= 36)
17515
2/4
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
464 if(!p_igetw(&mapinf.autopalette,f))
17516 return qe_invalid;
17517 1390 }
17518
17519
2/2
✓ Branch 0 taken 9245 times.
✓ Branch 1 taken 948 times.
10193 if (version >= 31)
17520 {
17521 static regions_data tmp_rd;
17522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 948 times.
948 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17523
2/2
✓ Branch 0 taken 7584 times.
✓ Branch 1 taken 948 times.
8532 for(int32_t j=0; j<8; j++)
17524 {
17525
2/2
✓ Branch 0 taken 60672 times.
✓ Branch 1 taken 7584 times.
68256 for(int32_t k=0; k<8; k++)
17526 {
17527
2/4
✓ Branch 0 taken 60672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60672 times.
✗ Branch 3 not taken.
60672 if(!p_getc(&rd.region_ids[j][k],f))
17528 {
17529 return qe_invalid;
17530 }
17531 60672 }
17532 7584 }
17533 948 }
17534 10193 }
17535
2/2
✓ Branch 0 taken 1403664 times.
✓ Branch 1 taken 10326 times.
1413990 for(int32_t j=0; j<screens_to_read; j++)
17536 {
17537 1403664 screen=i*MAPSCRS+j;
17538
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1403392 times.
1403664 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17539 1403664 scr->map = i;
17540 1403664 scr->screen = j;
17541
2/2
✓ Branch 0 taken 1385576 times.
✓ Branch 1 taken 18088 times.
1403664 if(valid)
17542
1/2
✓ Branch 0 taken 1385576 times.
✗ Branch 1 not taken.
1385576 readmapscreen(f, Header, scr, version, screen);
17543
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 else if (!should_skip)
17544
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 clear_screen(scr);
17545 1403664 }
17546
17547
2/2
✓ Branch 0 taken 10324 times.
✓ Branch 1 taken 2 times.
10326 if (should_skip)
17548 2 continue;
17549
17550
5/6
✓ Branch 0 taken 10156 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10138 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10324 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17551 {
17552 168 int32_t index = (i*MAPSCRS+132);
17553
17554
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17555
17556 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17557 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17558 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17559
17560
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17561 {
17562 504 screen=i*MAPSCRS+j;
17563
17564
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17565 504 TheMaps[screen].valid = mVERSION;
17566 504 TheMaps[screen].screen_midi = -1;
17567 504 TheMaps[screen].csensitive = 1;
17568 504 }
17569 168 }
17570
17571
5/6
✓ Branch 0 taken 10156 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10138 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10324 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17572 {
17573
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17574 {
17575 22848 screen=i*MAPSCRS+j;
17576
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17577
17578
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17579 {
17580
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17581
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17582
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17583 2924544 }
17584 22848 }
17585 168 }
17586 10324 }
17587 481 map_count = temp_map_count;
17588 481 return 0;
17589 481 }
17590
17591
17592 9042676 void update_combo(newcombo& cmb, word section_version)
17593 {
17594
2/2
✓ Branch 0 taken 1360657 times.
✓ Branch 1 taken 7682019 times.
9042676 if(section_version < 40)
17595 {
17596
3/3
✓ Branch 0 taken 5144 times.
✓ Branch 1 taken 45418 times.
✓ Branch 2 taken 7631457 times.
7682019 switch(cmb.type)
17597 {
17598 case cWATER: case cSHALLOWWATER:
17599 45418 cmb.attribytes[6] = iwRipples;
17600 45418 break;
17601 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17602 5144 cmb.attribytes[6] = iwTallGrass;
17603 5144 break;
17604 }
17605 7682019 }
17606
2/2
✓ Branch 0 taken 1013226 times.
✓ Branch 1 taken 8029450 times.
9042676 if(section_version < 49)
17607 {
17608
4/4
✓ Branch 0 taken 7994679 times.
✓ Branch 1 taken 34771 times.
✓ Branch 2 taken 15455 times.
✓ Branch 3 taken 7979224 times.
8029450 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17609 50226 cmb.sfx_landing = WAV_ZN1SPLASH;
17610 8029450 }
17611 9042676 }
17612 288 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17613 {
17614
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 24 times.
288 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17615 byte tempbyte;
17616
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17617 {
17618 287 reset_all_combo_animations();
17619 287 init_combo_classes();
17620 287 }
17621
17622 // combos
17623 288 word combos_used=0;
17624 int32_t dummy;
17625 byte padding;
17626 288 newcombo temp_combo;
17627
17628
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17629
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17630
1/2
✓ Branch 0 taken 18735360 times.
✗ Branch 1 not taken.
18735647 combobuf[q].clear();
17631
17632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(version < 0x174)
17633 {
17634 combos_used=1024;
17635 }
17636
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 18 times.
288 else if(version < 0x191)
17637 {
17638 18 combos_used=2048;
17639 18 }
17640 else
17641 {
17642
2/4
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
270 if(!p_igetw(&combos_used,f))
17643 {
17644 return qe_invalid;
17645 }
17646 }
17647
17648 //finally... section data
17649
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 288 times.
7547291 for(int32_t i=0; i<combos_used; i++)
17650 {
17651
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_combo.clear();
17652
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17653 7547003 int32_t temp_trigflags[6] = {0};
17654
17655
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if ( section_version >= 11 )
17656 {
17657
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17658 {
17659 return qe_invalid;
17660 }
17661 202968 }
17662 else
17663 {
17664
2/4
✓ Branch 0 taken 7344035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7344035 times.
✗ Branch 3 not taken.
7344035 if(!p_igetw(&temp_combo.tile,f))
17665 {
17666 return qe_invalid;
17667 }
17668 }
17669 7547003 temp_combo.o_tile = temp_combo.tile;
17670
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.flip,f))
17671 {
17672 return qe_invalid;
17673 }
17674
17675
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.walk,f))
17676 {
17677 return qe_invalid;
17678 }
17679
17680
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.type,f))
17681 {
17682 return qe_invalid;
17683 }
17684
17685
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.csets,f))
17686 {
17687 return qe_invalid;
17688 }
17689
17690
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7477229 times.
7547003 if(version < 0x193)
17691 {
17692
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17693 return qe_invalid;
17694
17695
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17696 return qe_invalid;
17697
17698
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17699 {
17700
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17701 {
17702 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17703 {
17704 if(!p_getc(&padding,f))
17705 return qe_invalid;
17706 }
17707 }
17708 36864 }
17709 69774 }
17710
2/2
✓ Branch 0 taken 7510139 times.
✓ Branch 1 taken 36864 times.
7547003 if(version >= 0x192)
17711 {
17712
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.frames,f))
17713 return qe_invalid;
17714
17715
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.speed,f))
17716 return qe_invalid;
17717
17718
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_igetw(&temp_combo.nextcombo,f))
17719 return qe_invalid;
17720
17721
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.nextcset,f))
17722 return qe_invalid;
17723
17724 //Base flag
17725
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=3)
17726
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.flag,f))
17727 return qe_invalid;
17728
17729
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=4)
17730 {
17731
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanim,f))
17732 return qe_invalid;
17733
17734
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_igetw(&temp_combo.nexttimer,f))
17735 return qe_invalid;
17736 4621731 }
17737
17738
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=5)
17739
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanimy,f))
17740 return qe_invalid;
17741
17742
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=6)
17743 {
17744
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.animflags,f))
17745 return qe_invalid;
17746
17747
1/2
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
4621731 if(section_version == 6)
17748 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17749 4621731 }
17750
17751
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=8) //combo Attributes[4] and userflags.
17752 {
17753
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17754
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17755 return qe_invalid;
17756
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17757 return qe_invalid;
17758
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17759
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17760 return qe_invalid;
17761 202968 }
17762
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=10) //combo trigger flags
17763 {
17764
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17765
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigflags[q],f))
17766 return qe_invalid;
17767 202968 }
17768
1/2
✓ Branch 0 taken 7307171 times.
✗ Branch 1 not taken.
7307171 else if(section_version==9) //combo trigger flags, V9 only had two indices
17769 {
17770 for ( int32_t q = 0; q < 2; q++ )
17771 if(!p_igetl(&temp_trigflags[q],f))
17772 return qe_invalid;
17773 }
17774
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 9)
17775
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17776 return qe_invalid;
17777
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 22)
17778
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17779 return qe_invalid;
17780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 24)
17781 {
17782 if(!p_getc(&temp_trigger.triggeritem,f))
17783 return qe_invalid;
17784 if(!p_getc(&tempbyte, f))
17785 return qe_invalid;
17786 temp_trigger.trigtimer = tempbyte;
17787 }
17788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 25)
17789 if(!p_getc(&temp_trigger.trigsfx,f))
17790 return qe_invalid;
17791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 27)
17792 if(!p_igetl(&temp_trigger.trigchange,f))
17793 return qe_invalid;
17794
17795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 29)
17796 {
17797 if(!p_igetw(&temp_trigger.trigprox,f))
17798 return qe_invalid;
17799 if(!p_getc(&tempbyte,f))
17800 return qe_invalid;
17801 temp_trigger.trigctr = tempbyte;
17802 if(!p_igetl(&temp_trigger.trigctramnt,f))
17803 return qe_invalid;
17804 }
17805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 30)
17806 if(!p_getc(&temp_trigger.triglbeam,f))
17807 return qe_invalid;
17808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 31)
17809 {
17810 if(!p_getc(&temp_trigger.trigcschange,f))
17811 return qe_invalid;
17812 if(!p_igetw(&temp_trigger.spawnitem,f))
17813 return qe_invalid;
17814 if(!p_igetw(&temp_trigger.spawnenemy,f))
17815 return qe_invalid;
17816 if(!p_getc(&temp_trigger.exstate,f))
17817 return qe_invalid;
17818 if(!p_igetl(&temp_trigger.spawnip,f))
17819 return qe_invalid;
17820 if(!p_getc(&temp_trigger.trigcopycat,f))
17821 return qe_invalid;
17822 }
17823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 32)
17824 if(!p_getc(&temp_trigger.trigcooldown,f))
17825 return qe_invalid;
17826
17827
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=12) //combo label
17828 {
17829 char label[12];
17830 202968 label[11] = '\0';
17831
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17832
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17833 return qe_invalid;
17834
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17835 202968 }
17836
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=13) //attribytes[4]
17837
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17838
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17839 202968 return qe_invalid;
17840 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17841 * This fixes a poor implementation of a ->next flag bug thing.
17842 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17843 * there was a version bump a few weeks before a change that broke stuff.
17844 */
17845
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if (section_version >= 13 && section_version < 21)
17846 {
17847 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17848 }
17849 //combo scripts
17850
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=14)
17851 {
17852
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17853 return qe_invalid;
17854
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17855
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17856 return qe_invalid;
17857 202968 }
17858
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=15)
17859 {
17860
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17861
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17862
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17863
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17864 202968 }
17865
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=17) //attribytes[4]
17866 {
17867
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17868
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17869 return qe_invalid;
17870
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17871
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17872 return qe_invalid;
17873 202968 }
17874
17875
2/2
✓ Branch 0 taken 7477229 times.
✓ Branch 1 taken 32910 times.
7510139 if(version < 0x193)
17876
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17877
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17878 32910 return qe_invalid;
17879 7510139 }
17880
17881 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17882
3/6
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4621731 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7547003 if((version < 0x211)||((version == 0x211)&&(build<7)))
17883 {
17884
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17885 {
17886
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17887 {
17888 case 130:
17889 temp_combo.tile = 132;
17890 break;
17891
17892 case 131:
17893 temp_combo.tile = 133;
17894 break;
17895
17896 case 132:
17897 temp_combo.tile = 130;
17898 break;
17899
17900 case 133:
17901 temp_combo.tile = 131;
17902 break;
17903 }
17904 39936 }
17905 2925272 }
17906
17907
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 15)
17908 7344035 temp_combo.o_tile = temp_combo.tile;
17909
17910
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version<18) //upper bits for .walk
17911 7344035 temp_combo.walk |= 0xF0;
17912
17913
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 19)
17914
2/2
✓ Branch 0 taken 29376140 times.
✓ Branch 1 taken 7344035 times.
36720175 for(int32_t q = 0; q < 4; ++q)
17915 36720175 temp_combo.attributes[q] *= 10000L;
17916
17917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 23)
17918 {
17919
2/2
✓ Branch 0 taken 15235 times.
✓ Branch 1 taken 7531768 times.
7547003 switch(temp_combo.type) //TRIGFLAG_CMBTYPEFX now required for combotype-specific effects
17920 {
17921 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17922 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17923 case cTRIGGERGENERIC: case cCSWITCH:
17924 15235 temp_trigflags[TRIGFLAG_CMBTYPEFX/32] |= 1<<(TRIGFLAG_CMBTYPEFX%32);
17925 15235 }
17926 7547003 }
17927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 25)
17928 {
17929
2/2
✓ Branch 0 taken 27396 times.
✓ Branch 1 taken 7519607 times.
7547003 switch(temp_combo.type)
17930 {
17931 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27396 times.
27396 if(!(temp_combo.usrflags & cflag3))
17933 27396 temp_combo.attribytes[3] = WAV_DOOR;
17934 27396 temp_combo.usrflags &= ~cflag3;
17935 27396 break;
17936 }
17937 7547003 }
17938
17939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 26)
17940
2/2
✓ Branch 0 taken 7545882 times.
✓ Branch 1 taken 1121 times.
7548124 if(temp_combo.type == cARMOS)
17941
1/2
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
1121 if(temp_combo.usrflags & cflag1)
17942 temp_combo.usrflags |= cflag3;
17943
17944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 27)
17945 {
17946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(temp_trigflags[0] & 0x00040000) //'next'
17947 temp_trigger.trigchange = 1;
17948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 else if(temp_trigflags[0] & 0x00080000) //'prev'
17949 temp_trigger.trigchange = -1;
17950 7547003 else temp_trigger.trigchange = 0;
17951 7547003 temp_trigflags[0] &= ~(0x00040000|0x00080000);
17952 7547003 }
17953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 28)
17954 {
17955
2/2
✓ Branch 0 taken 15512 times.
✓ Branch 1 taken 7531491 times.
7547003 switch(temp_combo.type)
17956 {
17957 case cLOCKBLOCK: case cLOCKEDCHEST:
17958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15512 times.
15512 if(temp_combo.usrflags & cflag7)
17959 temp_combo.usrflags |= cflag8;
17960 15512 else temp_combo.usrflags &= ~cflag8;
17961 15512 temp_combo.usrflags &= ~cflag7;
17962 15512 break;
17963 }
17964
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 7546245 times.
7547003 switch(temp_combo.type)
17965 {
17966 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17967 758 temp_combo.attrishorts[2] = -1;
17968 758 temp_combo.usrflags |= cflag7;
17969 758 break;
17970 }
17971 7547003 }
17972
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 20)
17973 {
17974 7344035 temp_combo.genflags = 0;
17975
2/2
✓ Branch 0 taken 143987 times.
✓ Branch 1 taken 7200048 times.
7344035 switch(temp_combo.type)
17976 {
17977 case cPUSH_WAIT: case cPUSH_HEAVY:
17978 case cPUSH_HW: case cL_STATUE:
17979 case cR_STATUE: case cPUSH_HEAVY2:
17980 case cPUSH_HW2: case cPOUND:
17981 case cC_STATUE: case cMIRROR:
17982 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17983 case cMAGICPRISM: case cMAGICPRISM4:
17984 case cMAGICSPONGE: case cEYEBALL_A:
17985 case cEYEBALL_B: case cEYEBALL_4:
17986 case cBUSH: case cFLOWERS:
17987 case cLOCKBLOCK: case cLOCKBLOCK2:
17988 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17989 case cCHEST: case cCHEST2:
17990 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17991 case cBOSSCHEST: case cBOSSCHEST2:
17992 case cBUSHNEXT: case cBUSHTOUCHY:
17993 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17994 case cSIGNPOST: case cCSWITCHBLOCK:
17995 case cTORCH: case cTRIGGERGENERIC:
17996
1/2
✓ Branch 0 taken 143987 times.
✗ Branch 1 not taken.
143987 if(temp_combo.usrflags & cflag16)
17997 {
17998 temp_combo.genflags |= cflag1;
17999 temp_combo.usrflags &= ~cflag16;
18000 }
18001 143987 break;
18002 }
18003 7344035 }
18004
18005
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_trigger.trigger_flags.clear();
18006
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 1449024576 times.
1456571579 for(size_t q = 0; q < 32*6; ++q)
18007 {
18008 1449024576 auto ind = q/32;
18009 1449024576 auto bit = 1<<(q%32);
18010
2/2
✓ Branch 0 taken 1449008300 times.
✓ Branch 1 taken 16276 times.
1449024576 if(temp_trigflags[ind] & bit)
18011
1/2
✓ Branch 0 taken 16276 times.
✗ Branch 1 not taken.
16276 temp_trigger.trigger_flags.set(q, true);
18012 1449024576 }
18013
18014
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15274 times.
✓ Branch 3 taken 7531729 times.
7547003 if(temp_trigger.is_blank())
18015 7531729 temp_combo.triggers.clear();
18016
18017 7547003 update_combo(temp_combo, section_version);
18018
18019
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7532084 times.
✓ Branch 3 taken 14919 times.
7547003 if(i>=start_combo && !should_skip)
18020 {
18021
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18022 {
18023 temp_combo.script = 0;
18024 for(int q = 0; q < 8; ++q)
18025 temp_combo.initd[q] = 0;
18026 }
18027
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 combobuf[i] = temp_combo;
18028 7532084 }
18029 7547003 }
18030
18031
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 1 times.
288 if (should_skip)
18032 1 return 0;
18033
18034
5/6
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
287 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18035 {
18036
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18037 {
18038
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18039 {
18040 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18041 215 }
18042 1501440 }
18043 23 }
18044
18045 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18046
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
287 if(version == 0x210 && get_app_id() != App::zquest)
18047 {
18048
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18049
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
18050 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18051 59 }
18052
18053
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<7)
18054 {
18055
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18056 {
18057
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
18058 {
18059 case cSLASH:
18060 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
18061 853 break;
18062
18063 case cSLASHITEM:
18064 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18065 791 break;
18066
18067 case cBUSH:
18068 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
18069 603 break;
18070
18071 case cFLOWERS:
18072 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18073 174 break;
18074
18075 case cTALLGRASS:
18076 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18077 531 break;
18078
18079 case cSLASHNEXT:
18080 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18081 break;
18082
18083 case cSLASHNEXTITEM:
18084 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18085 break;
18086
18087 case cBUSHNEXT:
18088 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18089 break;
18090 }
18091 5352960 }
18092 82 }
18093
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
287 if (section_version < 16)
18094 {
18095
2/2
✓ Branch 0 taken 18408960 times.
✓ Branch 1 taken 282 times.
18409242 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18096 {
18097
2/2
✓ Branch 0 taken 18380119 times.
✓ Branch 1 taken 28841 times.
18408960 if (combobuf[tmpcounter].type == cWATER)
18098 {
18099 28841 combobuf[tmpcounter].attributes[0] = 40000L;
18100 28841 }
18101 18408960 }
18102 282 }
18103
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 3 times.
287 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18104 {
18105 3 combobuf[0].walk = 0xF0;
18106 3 combobuf[0].type = 0;
18107 3 combobuf[0].flag = 0;
18108 3 }
18109
18110 //Now for the new combo alias reset
18111
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<2)
18112 {
18113
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18114 {
18115 671744 combo_aliases[j].width = 0;
18116 671744 combo_aliases[j].height = 0;
18117 671744 combo_aliases[j].layermask = 0;
18118
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
18119
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
18120 671744 }
18121 82 }
18122
18123
18124
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations();
18125
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations2();
18126 287 return 0;
18127 288 }
18128
18129 12915 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
18130 {
18131 byte tempbyte;
18132
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 5335 times.
12915 if(s_version >= 52)
18133
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getcstr(&temp_trigger.label,f))
18134 return qe_invalid;
18135
18136
2/2
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 5089 times.
12915 if(s_version < 57)
18137 {
18138 7826 int32_t temp_trigflags[6] = {0};
18139 7826 int numtrigs = s_version < 36 ? 3 : 6;
18140
2/2
✓ Branch 0 taken 46098 times.
✓ Branch 1 taken 7826 times.
53924 for ( int32_t q = 0; q < numtrigs; q++ )
18141
1/2
✓ Branch 0 taken 46098 times.
✗ Branch 1 not taken.
46098 if(!p_igetl(&temp_trigflags[q],f))
18142 return qe_invalid;
18143 7826 temp_trigger.trigger_flags.clear();
18144
2/2
✓ Branch 0 taken 1475136 times.
✓ Branch 1 taken 7826 times.
1482962 for(size_t q = 0; q < 32*numtrigs; ++q)
18145 {
18146 1475136 auto ind = q/32;
18147 1475136 auto bit = 1<<(q%32);
18148
2/2
✓ Branch 0 taken 1461763 times.
✓ Branch 1 taken 13373 times.
1475136 if(temp_trigflags[ind] & bit)
18149 13373 temp_trigger.trigger_flags.set(q, true);
18150 1475136 }
18151 7826 }
18152
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 else if(!p_getbitstr(&temp_trigger.trigger_flags,f))
18153 return qe_invalid;
18154
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.triggerlevel,f))
18155 return qe_invalid;
18156
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.triggerbtn,f))
18157 return qe_invalid;
18158
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.triggeritem,f))
18159 return qe_invalid;
18160
2/2
✓ Branch 0 taken 5335 times.
✓ Branch 1 taken 7580 times.
12915 if(s_version >= 53)
18161 {
18162
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetw(&temp_trigger.trigtimer,f))
18163 return qe_invalid;
18164 5335 }
18165 else
18166 {
18167
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if(!p_getc(&tempbyte, f))
18168 return qe_invalid;
18169 7580 temp_trigger.trigtimer = tempbyte;
18170 }
18171
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigsfx,f))
18172 return qe_invalid;
18173
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.trigchange,f))
18174 return qe_invalid;
18175
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.trigprox,f))
18176 return qe_invalid;
18177
2/2
✓ Branch 0 taken 5335 times.
✓ Branch 1 taken 7580 times.
12915 if(s_version >= 53)
18178 {
18179
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetw(&temp_trigger.trigctr,f))
18180 return qe_invalid;
18181 5335 }
18182 else
18183 {
18184
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if(!p_getc(&tempbyte,f))
18185 return qe_invalid;
18186 7580 temp_trigger.trigctr = tempbyte;
18187 }
18188
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.trigctramnt,f))
18189 return qe_invalid;
18190
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.triglbeam,f))
18191 return qe_invalid;
18192
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigcschange,f))
18193 return qe_invalid;
18194
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.spawnitem,f))
18195 return qe_invalid;
18196
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.spawnenemy,f))
18197 return qe_invalid;
18198
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.exstate,f))
18199 return qe_invalid;
18200
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.spawnip,f))
18201 return qe_invalid;
18202
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigcopycat,f))
18203 return qe_invalid;
18204
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigcooldown,f))
18205 return qe_invalid;
18206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12915 times.
12915 if(s_version >= 35)
18207 {
18208
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.prompt_cid,f))
18209 return qe_invalid;
18210
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.prompt_cs,f))
18211 return qe_invalid;
18212
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.prompt_x,f))
18213 return qe_invalid;
18214
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.prompt_y,f))
18215 return qe_invalid;
18216 12915 }
18217
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12629 times.
12915 if(s_version >= 36)
18218 {
18219
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_getc(&temp_trigger.trig_lstate,f))
18220 return qe_invalid;
18221
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_getc(&temp_trigger.trig_gstate,f))
18222 return qe_invalid;
18223
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_igetl(&temp_trigger.trig_statetime,f))
18224 return qe_invalid;
18225 12629 }
18226
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12629 times.
12915 if(s_version >= 37)
18227 {
18228
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_igetw(&temp_trigger.trig_genscr,f))
18229 return qe_invalid;
18230 12629 }
18231
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 12481 times.
12915 if(s_version >= 38)
18232 {
18233
1/2
✓ Branch 0 taken 12481 times.
✗ Branch 1 not taken.
12481 if(!p_getc(&temp_trigger.trig_group,f))
18234 return qe_invalid;
18235
1/2
✓ Branch 0 taken 12481 times.
✗ Branch 1 not taken.
12481 if(!p_igetw(&temp_trigger.trig_group_val,f))
18236 return qe_invalid;
18237 12481 }
18238
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 12445 times.
12915 if(s_version >= 45)
18239 {
18240
1/2
✓ Branch 0 taken 12445 times.
✗ Branch 1 not taken.
12445 if(!p_getc(&temp_trigger.exdoor_dir,f))
18241 return qe_invalid;
18242
1/2
✓ Branch 0 taken 12445 times.
✗ Branch 1 not taken.
12445 if(!p_getc(&temp_trigger.exdoor_ind,f))
18243 return qe_invalid;
18244 12445 }
18245
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5803 times.
12915 if(s_version >= 46)
18246 {
18247
2/2
✓ Branch 0 taken 2673 times.
✓ Branch 1 taken 3130 times.
5803 if (s_version >= 59)
18248 {
18249
1/2
✓ Branch 0 taken 2673 times.
✗ Branch 1 not taken.
2673 if(!p_igetw(&temp_trigger.trig_levelitems,f))
18250 return qe_invalid;
18251 2673 }
18252 else
18253 {
18254
1/2
✓ Branch 0 taken 3130 times.
✗ Branch 1 not taken.
3130 if(!p_getc(&tempbyte,f))
18255 return qe_invalid;
18256 3130 temp_trigger.trig_levelitems = word(tempbyte);
18257 }
18258
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18259 return qe_invalid;
18260
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(s_version >= 48)
18261 {
18262
2/2
✓ Branch 0 taken 17409 times.
✓ Branch 1 taken 5803 times.
23212 for(int q = 0; q < 3; ++q)
18263
1/2
✓ Branch 0 taken 17409 times.
✗ Branch 1 not taken.
17409 if(!p_igetw(&temp_trigger.trigtint[q],f))
18264 return qe_invalid;
18265 5803 }
18266 else
18267 {
18268 for(int q = 0; q < 3; ++q)
18269 if(!p_getc(&temp_trigger.trigtint[q],f))
18270 return qe_invalid;
18271 for(int q = 0; q < 3; ++q)
18272 {
18273 int v = temp_trigger.trigtint[q];
18274 int va = abs(v);
18275 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18276 }
18277 }
18278
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18279 return qe_invalid;
18280
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18281 return qe_invalid;
18282
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigquaketime,f))
18283 return qe_invalid;
18284
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigwavytime,f))
18285 return qe_invalid;
18286
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18287 return qe_invalid;
18288
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18289 return qe_invalid;
18290
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18291 return qe_invalid;
18292
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18293 return qe_invalid;
18294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5803 times.
5803 if(!p_getc(&temp_trigger.trig_pushtime,f))
18295 return qe_invalid;
18296 5803 }
18297
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5803 times.
12915 if(s_version >= 47)
18298 {
18299
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18300 return qe_invalid;
18301 5803 }
18302
2/2
✓ Branch 0 taken 5335 times.
✓ Branch 1 taken 7580 times.
12915 if(s_version >= 53)
18303 {
18304
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.req_level_state, f))
18305 return qe_invalid;
18306
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18307 return qe_invalid;
18308
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18309 return qe_invalid;
18310
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18311 return qe_invalid;
18312
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18313 return qe_invalid;
18314
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18315 return qe_invalid;
18316
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18317 return qe_invalid;
18318
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18319 return qe_invalid;
18320
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetzf(&temp_trigger.player_bounce, f))
18321 return qe_invalid;
18322
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetzf(&temp_trigger.req_player_z, f))
18323 return qe_invalid;
18324 5335 }
18325 else
18326 {
18327 7580 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18328 7580 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18329 }
18330
2/2
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 5089 times.
12915 if(s_version >= 54)
18331 {
18332
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_getc(&temp_trigger.req_player_dir,f))
18333 return qe_invalid;
18334
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18335 return qe_invalid;
18336
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18337 return qe_invalid;
18338
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18339 return qe_invalid;
18340
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18341 return qe_invalid;
18342
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.req_player_x, f))
18343 return qe_invalid;
18344
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.req_player_y, f))
18345 return qe_invalid;
18346 5089 }
18347
2/2
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 5089 times.
12915 if(s_version >= 56)
18348 {
18349
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_getc(&temp_trigger.dest_player_dir, f))
18350 return qe_invalid;
18351
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetl(&temp_trigger.force_ice_combo, f))
18352 return qe_invalid;
18353
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.force_ice_vx, f))
18354 return qe_invalid;
18355
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.force_ice_vy, f))
18356 return qe_invalid;
18357 5089 }
18358
2/2
✓ Branch 0 taken 10242 times.
✓ Branch 1 taken 2673 times.
12915 if(s_version >= 58)
18359 {
18360
1/2
✓ Branch 0 taken 2673 times.
✗ Branch 1 not taken.
2673 if(!p_igetzf(&temp_trigger.trig_gravity, f))
18361 return qe_invalid;
18362
1/2
✓ Branch 0 taken 2673 times.
✗ Branch 1 not taken.
2673 if(!p_igetzf(&temp_trigger.trig_terminal_v, f))
18363 return qe_invalid;
18364 2673 }
18365 12915 return 0;
18366 12915 }
18367
18368 1495673 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18369 {
18370 byte tempbyte;
18371 word combo_has_flags;
18372
2/2
✓ Branch 0 taken 654185 times.
✓ Branch 1 taken 841488 times.
1495673 if(s_version < 55)
18373 {
18374
1/2
✓ Branch 0 taken 654185 times.
✗ Branch 1 not taken.
654185 if(!p_getc(&tempbyte,f))
18375 return qe_invalid;
18376 654185 combo_has_flags = tempbyte;
18377 654185 }
18378 else
18379 {
18380
1/2
✓ Branch 0 taken 841488 times.
✗ Branch 1 not taken.
841488 if(!p_igetw(&combo_has_flags,f))
18381 return qe_invalid;
18382 }
18383
18384 1495673 temp_combo.clear();
18385
2/2
✓ Branch 0 taken 305822 times.
✓ Branch 1 taken 1189851 times.
1495673 if(combo_has_flags)
18386 {
18387
2/2
✓ Branch 0 taken 521566 times.
✓ Branch 1 taken 668285 times.
1189851 if(combo_has_flags&CHAS_BASIC)
18388 {
18389
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_igetl(&temp_combo.tile,f))
18390 return qe_invalid;
18391 668285 temp_combo.o_tile = temp_combo.tile;
18392
18393
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.flip,f))
18394 return qe_invalid;
18395
18396
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.walk,f))
18397 return qe_invalid;
18398
18399
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.type,f))
18400 return qe_invalid;
18401
18402
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.flag,f))
18403 return qe_invalid;
18404
18405
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.csets,f))
18406 return qe_invalid;
18407 668285 }
18408
2/2
✓ Branch 0 taken 1186994 times.
✓ Branch 1 taken 2857 times.
1189851 if(combo_has_flags&CHAS_SCRIPT)
18409 {
18410
2/2
✓ Branch 0 taken 2827 times.
✓ Branch 1 taken 30 times.
2857 if (s_version>=41)
18411 {
18412 2827 p_getcstr(&temp_combo.label, f);
18413 2827 }
18414 else
18415 {
18416 char label[12];
18417 30 label[11] = '\0';
18418
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18419
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18420 return qe_invalid;
18421 30 temp_combo.label = label;
18422 }
18423
18424
1/2
✓ Branch 0 taken 2857 times.
✗ Branch 1 not taken.
2857 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18425 2857 auto initd_count = s_version >= 43 ? 8 : 2;
18426
2/2
✓ Branch 0 taken 22676 times.
✓ Branch 1 taken 2857 times.
25533 for ( int32_t q = 0; q < initd_count; q++ )
18427
1/2
✓ Branch 0 taken 22676 times.
✗ Branch 1 not taken.
22676 if(!p_igetl(&temp_combo.initd[q],f))
18428 return qe_invalid;
18429 2857 }
18430
2/2
✓ Branch 0 taken 1062510 times.
✓ Branch 1 taken 127341 times.
1189851 if(combo_has_flags&CHAS_ANIM)
18431 {
18432
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.frames,f))
18433 return qe_invalid;
18434
18435
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.speed,f))
18436 return qe_invalid;
18437
18438
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_igetw(&temp_combo.nextcombo,f))
18439 return qe_invalid;
18440
18441
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.nextcset,f))
18442 return qe_invalid;
18443
18444
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.skipanim,f))
18445 return qe_invalid;
18446
18447
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.skipanimy,f))
18448 return qe_invalid;
18449
18450
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.animflags,f))
18451 return qe_invalid;
18452 127341 }
18453
2/2
✓ Branch 0 taken 1132522 times.
✓ Branch 1 taken 57329 times.
1189851 if(combo_has_flags&CHAS_ATTRIB)
18454 {
18455
2/2
✓ Branch 0 taken 229316 times.
✓ Branch 1 taken 57329 times.
286645 for ( int32_t q = 0; q < 4; q++ )
18456
1/2
✓ Branch 0 taken 229316 times.
✗ Branch 1 not taken.
229316 if(!p_igetl(&temp_combo.attributes[q],f))
18457 return qe_invalid;
18458
2/2
✓ Branch 0 taken 458632 times.
✓ Branch 1 taken 57329 times.
515961 for ( int32_t q = 0; q < 8; q++ )
18459
1/2
✓ Branch 0 taken 458632 times.
✗ Branch 1 not taken.
458632 if(!p_getc(&temp_combo.attribytes[q],f))
18460 return qe_invalid;
18461
2/2
✓ Branch 0 taken 458632 times.
✓ Branch 1 taken 57329 times.
515961 for ( int32_t q = 0; q < 8; q++ )
18462
1/2
✓ Branch 0 taken 458632 times.
✗ Branch 1 not taken.
458632 if(!p_igetw(&temp_combo.attrishorts[q],f))
18463 return qe_invalid;
18464 57329 }
18465
2/2
✓ Branch 0 taken 1177382 times.
✓ Branch 1 taken 12469 times.
1189851 if(combo_has_flags&CHAS_FLAG)
18466 {
18467
1/2
✓ Branch 0 taken 12469 times.
✗ Branch 1 not taken.
12469 if(!p_igetl(&temp_combo.usrflags,f))
18468 return qe_invalid;
18469
1/2
✓ Branch 0 taken 12469 times.
✗ Branch 1 not taken.
12469 if(!p_igetw(&temp_combo.genflags,f))
18470 return qe_invalid;
18471 12469 }
18472
2/2
✓ Branch 0 taken 1177013 times.
✓ Branch 1 taken 12838 times.
1189851 if(combo_has_flags&CHAS_TRIG)
18473 {
18474 12838 byte count = 1;
18475
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 5258 times.
12838 if(s_version >= 52)
18476
1/2
✓ Branch 0 taken 5258 times.
✗ Branch 1 not taken.
5258 if(!p_getc(&count, f))
18477 return qe_invalid;
18478
18479
2/2
✓ Branch 0 taken 12915 times.
✓ Branch 1 taken 12838 times.
25753 for(byte q = 0; q < count; ++q)
18480 {
18481 12915 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18482 12915 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18483
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(ret)
18484 return ret;
18485 12915 }
18486
18487
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 5258 times.
12838 if(s_version < 52)
18488 {
18489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7580 times.
7580 if(!temp_combo.triggers.empty())
18490 7580 temp_combo.only_gentrig = (temp_combo.triggers[0].trigger_flags.get(TRIGFLAG_ONLYGENTRIG)) ? 1 : 0;
18491 7580 }
18492
1/2
✓ Branch 0 taken 5258 times.
✗ Branch 1 not taken.
5258 else if(!p_getc(&temp_combo.only_gentrig,f))
18493 return qe_invalid;
18494 12838 }
18495
2/2
✓ Branch 0 taken 348222 times.
✓ Branch 1 taken 841629 times.
1189851 if(combo_has_flags&CHAS_LIFT)
18496 {
18497
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_igetw(&temp_combo.liftcmb,f))
18498 return qe_invalid;
18499
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftcs,f))
18500 return qe_invalid;
18501
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_igetw(&temp_combo.liftundercmb,f))
18502 return qe_invalid;
18503
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftundercs,f))
18504 return qe_invalid;
18505
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftdmg,f))
18506 return qe_invalid;
18507
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftlvl,f))
18508 return qe_invalid;
18509
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftitm,f))
18510 return qe_invalid;
18511
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftflags,f))
18512 return qe_invalid;
18513
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftgfx,f))
18514 return qe_invalid;
18515
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftsprite,f))
18516 return qe_invalid;
18517
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftsfx,f))
18518 return qe_invalid;
18519
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18520 return qe_invalid;
18521
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftbreaksfx,f))
18522 return qe_invalid;
18523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841629 times.
841629 if(s_version >= 34)
18524 {
18525
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.lifthei,f))
18526 return qe_invalid;
18527
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.lifttime,f))
18528 return qe_invalid;
18529 841629 }
18530
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 841615 times.
841629 if(s_version >= 39)
18531 {
18532
1/2
✓ Branch 0 taken 841615 times.
✗ Branch 1 not taken.
841615 if(!p_getc(&temp_combo.lift_parent_item,f))
18533 return qe_invalid;
18534 841615 }
18535 841629 auto& weap_data = temp_combo.lift_weap_data;
18536
4/4
✓ Branch 0 taken 841512 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 841488 times.
✓ Branch 3 taken 24 times.
841629 if(s_version >= 51 && s_version < 55)
18537 {
18538
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.light_rads[WPNSPR_BASE],f))
18539 return qe_invalid;
18540
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.glow_shape,f))
18541 return qe_invalid;
18542 24 }
18543
18544
2/2
✓ Branch 0 taken 841488 times.
✓ Branch 1 taken 141 times.
841629 if(s_version >= 55)
18545 {
18546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841488 times.
841488 if(auto ret = read_weap_data(weap_data, f))
18547 return ret;
18548 841488 }
18549 else
18550 {
18551 141 auto const& pitm = itemsbuf[temp_combo.lift_parent_item];
18552 141 auto weap_glow = weap_data.light_rads[WPNSPR_BASE];
18553
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 135 times.
141 switch(pitm.type)
18554 {
18555 case itype_bomb:
18556 case itype_sbomb:
18557 6 weap_data = pitm.weap_data;
18558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(weap_data.wflags & WFLAG_UPDATE_IGNITE_SPRITE))
18559 {
18560 6 weap_data.flags |= wdata_glow_rad;
18561 6 weap_data.light_rads[WPNSPR_BASE] = weap_glow;
18562 6 }
18563 6 break;
18564 default:
18565 135 weap_data.wflags |= WFLAG_BREAK_WHEN_LANDING;
18566 135 weap_data.flags |= wdata_glow_rad;
18567 135 }
18568 141 weap_data.moveflags |= move_obeys_grav|move_can_pitfall;
18569
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 81 times.
141 if(temp_combo.liftflags & LF_BREAKONSOLID)
18570 60 weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
18571 }
18572 841629 }
18573
18574
2/2
✓ Branch 0 taken 1156073 times.
✓ Branch 1 taken 33778 times.
1189851 if(combo_has_flags&CHAS_GENERAL)
18575 {
18576
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.speed_mult,f))
18577 return qe_invalid;
18578
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.speed_div,f))
18579 return qe_invalid;
18580
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_igetzf(&temp_combo.speed_add,f))
18581 return qe_invalid;
18582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33778 times.
33778 if(s_version >= 42)
18583 {
18584
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_appear,f))
18585 return qe_invalid;
18586
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_disappear,f))
18587 return qe_invalid;
18588
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_loop,f))
18589 return qe_invalid;
18590
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_walking,f))
18591 return qe_invalid;
18592
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_standing,f))
18593 return qe_invalid;
18594
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_appear,f))
18595 return qe_invalid;
18596
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_disappear,f))
18597 return qe_invalid;
18598
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_walking,f))
18599 return qe_invalid;
18600
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_standing,f))
18601 return qe_invalid;
18602 33778 }
18603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33778 times.
33778 if(s_version >= 44)
18604 {
18605
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_tap,f))
18606 return qe_invalid;
18607 33778 }
18608
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 33412 times.
33778 if(s_version >= 49)
18609 {
18610
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_landing,f))
18611 return qe_invalid;
18612 33412 }
18613
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 33412 times.
33778 if(s_version >= 50)
18614 {
18615
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.spr_falling,f))
18616 return qe_invalid;
18617
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.spr_drowning,f))
18618 return qe_invalid;
18619
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18620 return qe_invalid;
18621
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_falling,f))
18622 return qe_invalid;
18623
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_drowning,f))
18624 return qe_invalid;
18625
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18626 return qe_invalid;
18627 33412 }
18628
2/2
✓ Branch 0 taken 4704 times.
✓ Branch 1 taken 29074 times.
33778 if(s_version >= 56)
18629 {
18630
1/2
✓ Branch 0 taken 29074 times.
✗ Branch 1 not taken.
29074 if(!p_igetzf(&temp_combo.z_height,f))
18631 return qe_invalid;
18632
1/2
✓ Branch 0 taken 29074 times.
✗ Branch 1 not taken.
29074 if(!p_igetzf(&temp_combo.z_step_height,f))
18633 return qe_invalid;
18634 29074 }
18635
2/2
✓ Branch 0 taken 17745 times.
✓ Branch 1 taken 16033 times.
33778 if(s_version >= 60)
18636 {
18637
1/2
✓ Branch 0 taken 16033 times.
✗ Branch 1 not taken.
16033 if(!p_getc(&temp_combo.dive_under_level,f))
18638 return qe_invalid;
18639 16033 }
18640 33778 }
18641
1/2
✓ Branch 0 taken 1189851 times.
✗ Branch 1 not taken.
1189851 if(combo_has_flags&CHAS_MISC_WEAP_DATA)
18642 {
18643 if(auto ret = read_weap_data(temp_combo.misc_weap_data, f))
18644 return ret;
18645 }
18646 1189851 }
18647 1495673 update_combo(temp_combo, s_version);
18648 1495673 return 0;
18649 1495673 }
18650
18651 481 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18652 {
18653
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18654
18655 481 word section_version=0;
18656 481 word combos_used=0;
18657 int32_t dummy;
18658 byte padding;
18659 481 newcombo temp_combo;
18660
18661
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
18662 {
18663
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 reset_all_combo_animations();
18664
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 init_combo_classes();
18665
18666
2/2
✓ Branch 0 taken 31334400 times.
✓ Branch 1 taken 480 times.
31334880 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18667
1/2
✓ Branch 0 taken 31334400 times.
✗ Branch 1 not taken.
31334400 combobuf[q].clear();
18668 480 }
18669
18670
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 if(version > 0x192) //Version info
18671 {
18672
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&section_version,f))
18673 {
18674 return qe_invalid;
18675 }
18676 457 FFCore.quest_format[vCombos] = section_version;
18677
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
18678 {
18679 return qe_invalid;
18680 }
18681
18682 //section size
18683
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
18684 {
18685 return qe_invalid;
18686 }
18687 457 }
18688
18689
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 288 times.
481 if(section_version > 32) //Cleanup time!
18690 {
18691
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&combos_used,f))
18692 {
18693 return qe_invalid;
18694 }
18695
2/2
✓ Branch 0 taken 1495673 times.
✓ Branch 1 taken 193 times.
1495866 for(int32_t i=0; i<combos_used; i++)
18696 {
18697
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 auto ret = readcombo_loop(f,section_version,temp_combo);
18698
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 if(ret) return ret;
18699
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 if(i>=start_combo)
18700 {
18701
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18702 {
18703 temp_combo.script = 0;
18704 for(int q = 0; q < 8; ++q)
18705 temp_combo.initd[q] = 0;
18706 }
18707
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 combobuf[i] = temp_combo;
18708 1495673 }
18709 1495673 }
18710 193 }
18711 else //Call the old function for all old versions
18712 {
18713
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(ret) return ret; //error, end read
18715 }
18716
18717
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1 times.
481 if (should_skip)
18718 1 return 0;
18719
18720
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 184 times.
480 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18721 {
18722 184 combobuf[0].walk = 0xF0;
18723 184 combobuf[0].type = 0;
18724 184 combobuf[0].flag = 0;
18725 184 }
18726
18727
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 setup_combo_animations();
18728
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 setup_combo_animations2();
18729 480 return 0;
18730 481 }
18731
18732 398 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18733 {
18734 //these are here to bypass compiler warnings about unused arguments
18735 398 Header=Header;
18736 398 version=version;
18737 398 build=build;
18738
18739 int32_t dummy;
18740 398 word sversion=0, c_sversion;
18741
18742 //section version info
18743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&sversion,f))
18744 {
18745 return qe_invalid;
18746 }
18747
18748 398 FFCore.quest_format[vComboAliases] = sversion;
18749
18750
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&c_sversion,f))
18751 {
18752 return qe_invalid;
18753 }
18754
18755 //section size
18756
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
18757 {
18758 return qe_invalid;
18759 }
18760
18761 398 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18762
18763
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18764 {
18765 200 max_num_combo_aliases = MAX250COMBOALIASES;
18766 200 }
18767
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18768 {
18769 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18770 }
18771
18772
2/2
✓ Branch 0 taken 2031616 times.
✓ Branch 1 taken 398 times.
2032014 for(int32_t j=0; j<max_num_combo_aliases; j++)
18773 {
18774 byte width,height,mask,tempcset;
18775 int32_t count;
18776 word tempword;
18777 byte tempbyte;
18778
18779
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_igetw(&tempword,f))
18780 {
18781 return qe_invalid;
18782 }
18783
18784 2031616 combo_aliases[j].combo = tempword;
18785
18786
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&tempbyte,f))
18787 {
18788 return qe_invalid;
18789 }
18790
18791 2031616 combo_aliases[j].cset = tempbyte;
18792
18793
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&width,f))
18794 {
18795 return qe_invalid;
18796 }
18797
18798
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&height,f))
18799 {
18800 return qe_invalid;
18801 }
18802
18803
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&mask,f))
18804 {
18805 return qe_invalid;
18806 }
18807
18808 2031616 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18809
18810 2031616 combo_aliases[j].width = width;
18811 2031616 combo_aliases[j].height = height;
18812 2031616 combo_aliases[j].layermask = mask;
18813 2031616 combo_aliases[j].combos.clear();
18814 2031616 combo_aliases[j].csets.clear();
18815
18816
2/2
✓ Branch 0 taken 2085218 times.
✓ Branch 1 taken 2031616 times.
4116834 for(int32_t k=0; k<count; k++)
18817 {
18818
1/2
✓ Branch 0 taken 2085218 times.
✗ Branch 1 not taken.
2085218 if(!p_igetw(&tempword,f))
18819 {
18820 return qe_invalid;
18821 }
18822
18823 2085218 combo_aliases[j].combos[k] = tempword;
18824 2085218 }
18825
18826
2/2
✓ Branch 0 taken 2085218 times.
✓ Branch 1 taken 2031616 times.
4116834 for(int32_t k=0; k<count; k++)
18827 {
18828
1/2
✓ Branch 0 taken 2085218 times.
✗ Branch 1 not taken.
2085218 if(!p_getc(&tempcset,f))
18829 {
18830 return qe_invalid;
18831 }
18832
18833 2085218 combo_aliases[j].csets[k] = tempcset;
18834 2085218 }
18835 2031616 }
18836
18837 //Combo pools!
18838 398 word num_combo_pools = 0;
18839
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 193 times.
398 if(sversion >= 4)
18840 {
18841
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if(!p_igetw(&num_combo_pools,f))
18842 {
18843 return qe_invalid;
18844 }
18845 193 }
18846
18847
2/2
✓ Branch 0 taken 3260416 times.
✓ Branch 1 taken 398 times.
3260814 for(combo_pool& pool : combo_pools)
18848 {
18849 3260416 pool.clear();
18850 }
18851
18852 398 combo_pool temp_cpool;
18853
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 398 times.
888 for(word cp = 0; cp < num_combo_pools; ++cp)
18854 {
18855 490 int32_t num_combos_in_pool = 0;
18856
2/4
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490 times.
✗ Branch 3 not taken.
490 if(!p_igetl(&num_combos_in_pool,f))
18857 {
18858 return qe_invalid;
18859 }
18860
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 96 times.
490 if(num_combos_in_pool < 1) continue; //nothing to read
18861
18862
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 temp_cpool.clear();
18863
18864 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18865
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 1775 times.
2169 for(auto q = 0; q < num_combos_in_pool; ++q)
18866 {
18867
2/4
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1775 times.
✗ Branch 3 not taken.
1775 if(!p_igetl(&cp_cid,f))
18868 {
18869 return qe_invalid;
18870 }
18871
2/4
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1775 times.
✗ Branch 3 not taken.
1775 if(!p_getc(&cp_cs,f))
18872 {
18873 return qe_invalid;
18874 }
18875
2/4
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1775 times.
✗ Branch 3 not taken.
1775 if(!p_igetw(&cp_quant,f))
18876 {
18877 return qe_invalid;
18878 }
18879
1/2
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
1775 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18880 1775 }
18881
18882
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 combo_pools[cp] = temp_cpool;
18883 394 }
18884
18885 //Autocombos!
18886 398 word num_combo_autos = 0;
18887
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 217 times.
398 if (sversion >= 5)
18888 {
18889
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_igetw(&num_combo_autos, f))
18890 {
18891 return qe_invalid;
18892 }
18893 181 }
18894
18895
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 3260416 times.
3260814 for (combo_auto& cauto : combo_autos)
18896 {
18897
1/2
✓ Branch 0 taken 3260416 times.
✗ Branch 1 not taken.
3260416 cauto.clear(true);
18898 }
18899
18900
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 combo_auto temp_cauto;
18901
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 398 times.
530 for (word ca = 0; ca < num_combo_autos; ++ca)
18902 {
18903 byte type;
18904 int32_t display_cid, erase_cid;
18905 byte flags, arg;
18906
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_getc(&type, f))
18907 {
18908 return qe_invalid;
18909 }
18910
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_igetl(&display_cid, f))
18911 {
18912 return qe_invalid;
18913 }
18914
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_igetl(&erase_cid, f))
18915 {
18916 return qe_invalid;
18917 }
18918
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_getc(&flags, f))
18919 {
18920 return qe_invalid;
18921 }
18922
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_getc(&arg, f))
18923 {
18924 return qe_invalid;
18925 }
18926 132 int32_t num_combos_in_cauto = 0;
18927
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_igetl(&num_combos_in_cauto, f))
18928 {
18929 return qe_invalid;
18930 }
18931
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 21 times.
132 if (num_combos_in_cauto < 1) continue; //nothing to read
18932
18933
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.clear();
18934
18935
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setType(type);
18936
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setDisplay(display_cid);
18937
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setEraseCombo(erase_cid);
18938
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setFlags(flags);
18939
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setArg(arg);
18940
18941 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18942
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 2437 times.
2548 for (auto q = 0; q < num_combos_in_cauto; ++q)
18943 {
18944
2/4
✓ Branch 0 taken 2437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
2437 if (!p_getc(&ca_ctype, f))
18945 {
18946 return qe_invalid;
18947 }
18948
2/4
✓ Branch 0 taken 2437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
2437 if (!p_igetl(&ca_cid, f))
18949 {
18950 return qe_invalid;
18951 }
18952
1/2
✓ Branch 0 taken 2437 times.
✗ Branch 1 not taken.
2437 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18953 2437 }
18954
18955
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 combo_autos[ca] = temp_cauto;
18956 111 }
18957
18958 398 return 0;
18959 398 }
18960
18961 804 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18962 {
18963
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18964
18965 //these are here to bypass compiler warnings about unused arguments
18966 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18967 //Capitalized cause it'll save you a headache. -Deedee
18968 804 start_cset=start_cset;
18969 804 max_csets=max_csets;
18970 804 word s_version=0;
18971
18972 miscQdata temp_misc;
18973 804 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18974
18975 byte temp_colordata[48];
18976 char temp_palname[PALNAMESIZE+1];
18977
18978 int32_t dummy;
18979 word palcycles;
18980
18981
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(version > 0x192)
18982 {
18983 //section version info
18984
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&s_version,f))
18985 {
18986 return qe_invalid;
18987 }
18988
18989 780 FFCore.quest_format[vCSets] = s_version;
18990
18991
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&dummy,f))
18992 {
18993 return qe_invalid;
18994 }
18995
18996 //section size
18997
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&dummy,f))
18998 {
18999 return qe_invalid;
19000 }
19001 780 }
19002
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 198 times.
804 if (s_version < 5)
19003 {
19004
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 582 times.
✓ Branch 3 taken 6 times.
606 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
19005
19006 //finally... section data
19007 606 int32_t q = 0;
19008 606 int32_t p = -15;
19009
2/2
✓ Branch 0 taken 145440 times.
✓ Branch 1 taken 606 times.
146046 for(int32_t i=0; i<oldpdTOTAL; ++i)
19010 {
19011 145440 memset(temp_colordata, 0, 48);
19012
19013
1/2
✓ Branch 0 taken 145440 times.
✗ Branch 1 not taken.
145440 if(!pfread(temp_colordata,48,f))
19014 {
19015 return qe_invalid;
19016 }
19017
19018
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 145200 times.
145440 if (should_skip)
19019 240 continue;
19020
19021 145200 memcpy(&colordata[q*48], temp_colordata, 48);
19022
19023 145200 ++q;
19024
8/8
✓ Branch 0 taken 135520 times.
✓ Branch 1 taken 9680 times.
✓ Branch 2 taken 10285 times.
✓ Branch 3 taken 125235 times.
✓ Branch 4 taken 1210 times.
✓ Branch 5 taken 9075 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1174 times.
145200 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
19025 {
19026
1/2
✓ Branch 0 taken 10249 times.
✗ Branch 1 not taken.
10249 if (s_version < 5) //Bumping up the size of level palettes
19027 {
19028 10249 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19029 10249 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19030 10249 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19031 10249 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19032 10249 q+=4;
19033 10249 }
19034 else
19035 {
19036 for(int m = 0; m < 4; ++m)
19037 {
19038 memset(temp_colordata, 0, 48);
19039 if(!pfread(temp_colordata,48,f))
19040 {
19041 return qe_invalid;
19042 }
19043 memcpy(&colordata[q*48], temp_colordata, 48);
19044 ++q;
19045 }
19046 }
19047 10249 }
19048 145200 ++p;
19049 145200 }
19050
19051
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 588 times.
606 if(RealOldVerion)
19052 {
19053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19054 {
19055 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19056 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19057 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
19058 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
19059 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
19060 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
19061 18 }
19062 18 }
19063 else
19064 {
19065 588 memset(temp_colordata, 0, 48);
19066
19067
2/2
✓ Branch 0 taken 1842204 times.
✓ Branch 1 taken 588 times.
1842792 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
19068 {
19069
1/2
✓ Branch 0 taken 1842204 times.
✗ Branch 1 not taken.
1842204 if(!pfread(temp_colordata,48,f))
19070 {
19071 return qe_invalid;
19072 }
19073
19074
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1839071 times.
1842204 if (should_skip)
19075 3133 continue;
19076
19077 1839071 memcpy(&colordata[q*48], temp_colordata, 48);
19078
19079 1839071 ++q;
19080
7/8
✓ Branch 0 taken 1839071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141467 times.
✓ Branch 3 taken 1697604 times.
✓ Branch 4 taken 1174 times.
✓ Branch 5 taken 140293 times.
✓ Branch 6 taken 1046 times.
✓ Branch 7 taken 128 times.
1839071 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
19081 {
19082
1/2
✓ Branch 0 taken 141339 times.
✗ Branch 1 not taken.
141339 if (s_version < 5) //Bumping up the size of level palettes
19083 {
19084 141339 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19085 141339 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19086 141339 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19087 141339 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19088 141339 q+=4;
19089 141339 }
19090 else
19091 {
19092 for(int m = 0; m < 4; ++m)
19093 {
19094 memset(temp_colordata, 0, 48);
19095 if(!pfread(temp_colordata,48,f))
19096 {
19097 return qe_invalid;
19098 }
19099 memcpy(&colordata[q*48], temp_colordata, 48);
19100 ++q;
19101 }
19102 }
19103 141339 }
19104 1839071 ++p;
19105 1839071 }
19106
19107
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 523 times.
588 if(s_version < 4)
19108 {
19109
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
19110 {
19111 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19112 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19113 64 }
19114 65 }
19115 else
19116 {
19117
2/2
✓ Branch 0 taken 1740544 times.
✓ Branch 1 taken 523 times.
1741067 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19118 {
19119
1/2
✓ Branch 0 taken 1740544 times.
✗ Branch 1 not taken.
1740544 if(!pfread(temp_colordata,48,f))
19120 {
19121 return qe_invalid;
19122 }
19123
19124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1740544 times.
1740544 if (should_skip)
19125 continue;
19126
19127 1740544 memcpy(&colordata[q*48], temp_colordata, 48);
19128 1740544 ++q;
19129
5/6
✓ Branch 0 taken 1740544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133888 times.
✓ Branch 3 taken 1606656 times.
✓ Branch 4 taken 1046 times.
✓ Branch 5 taken 132842 times.
1740544 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19130 {
19131
1/2
✓ Branch 0 taken 132842 times.
✗ Branch 1 not taken.
132842 if (s_version < 5) //Bumping up the size of level palettes
19132 {
19133 132842 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19134 132842 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19135 132842 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19136 132842 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19137 132842 q+=4;
19138 132842 }
19139 else
19140 {
19141 for(int m = 0; m < 4; ++m)
19142 {
19143 memset(temp_colordata, 0, 48);
19144 if(!pfread(temp_colordata,48,f))
19145 {
19146 return qe_invalid;
19147 }
19148 memcpy(&colordata[q*48], temp_colordata, 48);
19149 ++q;
19150 }
19151 }
19152 132842 }
19153 1740544 ++p;
19154 1740544 }
19155
19156 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19157 }
19158 }
19159 606 }
19160 else
19161 {
19162
2/2
✓ Branch 0 taken 1732302 times.
✓ Branch 1 taken 198 times.
1732500 for(int32_t i=0; i<pdTOTAL255; ++i)
19163 {
19164 1732302 memset(temp_colordata, 0, 48);
19165
19166
1/2
✓ Branch 0 taken 1732302 times.
✗ Branch 1 not taken.
1732302 if(!pfread(temp_colordata,48,f))
19167 {
19168 return qe_invalid;
19169 }
19170
19171 1732302 memcpy(&colordata[i*48], temp_colordata, 48);
19172 1732302 }
19173 }
19174
19175
4/4
✓ Branch 0 taken 803 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 153 times.
✓ Branch 3 taken 650 times.
804 if (!should_skip && s_version < 6)
19176 {
19177
2/2
✓ Branch 0 taken 272968800 times.
✓ Branch 1 taken 650 times.
272969450 for (int i = 0; i < psTOTAL255; i++)
19178 {
19179 272968800 colordata[i] = _rgb_scale_6[colordata[i]];
19180 272968800 }
19181 650 }
19182
19183
5/6
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 780 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
804 if((version < 0x192)||((version == 0x192)&&(build<76)))
19184 {
19185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19186 18 init_palnames();
19187 18 }
19188 else
19189 {
19190 786 int32_t palnamestoread = 0;
19191
19192
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 721 times.
786 if(s_version < 3)
19193 65 palnamestoread = OLDMAXLEVELS;
19194 else
19195 721 palnamestoread = 512;
19196
19197
2/2
✓ Branch 0 taken 385792 times.
✓ Branch 1 taken 786 times.
386578 for(int32_t i=0; i<palnamestoread; ++i)
19198 {
19199
1/2
✓ Branch 0 taken 385792 times.
✗ Branch 1 not taken.
385792 if(!p_getstr(temp_palname,PALNAMESIZE,f))
19200 {
19201 return qe_invalid;
19202 }
19203
19204
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 385536 times.
385792 if (!should_skip)
19205 385536 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19206 385792 }
19207
19208
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 785 times.
786 if (should_skip)
19209 1 return 0;
19210
19211
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 785 times.
17169 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19212 {
19213 16384 memset(palnames[i], 0, PALNAMESIZE);
19214 16384 }
19215 }
19216
19217
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 780 times.
803 if(version > 0x192)
19218 {
19219
2/2
✓ Branch 0 taken 199680 times.
✓ Branch 1 taken 780 times.
200460 for(int32_t i=0; i<256; i++)
19220 {
19221
2/2
✓ Branch 0 taken 599040 times.
✓ Branch 1 taken 199680 times.
798720 for(int32_t j=0; j<3; j++)
19222 {
19223 599040 temp_misc.cycles[i][j].first=0;
19224 599040 temp_misc.cycles[i][j].count=0;
19225 599040 temp_misc.cycles[i][j].speed=0;
19226 599040 }
19227 199680 }
19228
19229
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&palcycles,f))
19230 {
19231 return qe_invalid;
19232 }
19233
19234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if (palcycles > NUM_PAL_CYCLES)
19235 {
19236 return qe_invalid;
19237 }
19238
19239
2/2
✓ Branch 0 taken 22039 times.
✓ Branch 1 taken 780 times.
22819 for(int32_t i=0; i<palcycles; i++)
19240 {
19241
2/2
✓ Branch 0 taken 66117 times.
✓ Branch 1 taken 22039 times.
88156 for(int32_t j=0; j<3; j++)
19242 {
19243
1/2
✓ Branch 0 taken 66117 times.
✗ Branch 1 not taken.
66117 if(!p_getc(&temp_misc.cycles[i][j].first,f))
19244 {
19245 return qe_invalid;
19246 }
19247 66117 }
19248
19249
2/2
✓ Branch 0 taken 66117 times.
✓ Branch 1 taken 22039 times.
88156 for(int32_t j=0; j<3; j++)
19250 {
19251
1/2
✓ Branch 0 taken 66117 times.
✗ Branch 1 not taken.
66117 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19252 {
19253 return qe_invalid;
19254 }
19255 66117 }
19256
19257
2/2
✓ Branch 0 taken 66117 times.
✓ Branch 1 taken 22039 times.
88156 for(int32_t j=0; j<3; j++)
19258 {
19259
1/2
✓ Branch 0 taken 66117 times.
✗ Branch 1 not taken.
66117 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19260 {
19261 return qe_invalid;
19262 }
19263 66117 }
19264 22039 }
19265
19266 780 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19267 780 }
19268
19269 803 return 0;
19270 804 }
19271
19272 804 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19273 {
19274
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
19275
19276 804 int32_t tiles_used=0;
19277 804 word section_version = 0;
19278 804 int32_t section_size= 0;
19279 804 byte *temp_tile = new byte[tilesize(tf32Bit)];
19280
19281 //Tile Expansion
19282 //if ( version >= 0x254 && build >= 41 )
19283
4/4
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 600 times.
804 if (version < 0x254 && build < 41)
19284 {
19285 600 max_tiles = ZC250MAXTILES;
19286 600 }
19287
19288
19289
2/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19290 {
19291 if(!init_tiles_for_190(true, Header))
19292 {
19293 al_trace("Unable to initialize tiles\n");
19294 }
19295
19296 delete[] temp_tile;
19297 temp_tile=NULL;
19298 return 0;
19299 }
19300 else
19301 {
19302
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(version > 0x192)
19303 {
19304 //section version info
19305
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&section_version,f))
19306 {
19307 delete[] temp_tile;
19308 return qe_invalid;
19309 }
19310
19311 780 FFCore.quest_format[vTiles] = section_version;
19312
19313
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!read_deprecated_section_cversion(f))
19314 {
19315 delete[] temp_tile;
19316 return qe_invalid;
19317 }
19318
19319 //section size
19320
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&section_size,f))
19321 {
19322 delete[] temp_tile;
19323 return qe_invalid;
19324 }
19325 780 }
19326
19327 //if ( build < 41 )
19328 //{
19329 // tiles_used = ZC250MAXTILES;
19330 //}
19331
19332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(version < 0x174)
19333 {
19334 tiles_used=TILES_PER_PAGE*4;
19335 } //no expanded tile space
19336
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 786 times.
804 else if(version < 0x191)
19337 {
19338 18 tiles_used=OLDMAXTILES;
19339 18 }
19340 else
19341 {
19342 //finally... section data
19343
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
786 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19344 {
19345
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&tiles_used,f))
19346 {
19347 delete[] temp_tile;
19348 return qe_invalid;
19349 }
19350 198 }
19351 else
19352 {
19353
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(!p_igetw(&tiles_used,f))
19354 {
19355 delete[] temp_tile;
19356 return qe_invalid;
19357 }
19358 }
19359 }
19360
19361
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tiles_used=zc_min(tiles_used, max_tiles);
19362
19363 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19364 //if ( version < 0x254 && build < 41 )
19365
3/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if ( version < 0x254 || (version == 0x254 && build < 41) )
19366 //if ( build < 41 )
19367 {
19368
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19369 606 }
19370 else //2.55
19371 {
19372
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19373 }
19374
19375 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19376
19377
19378
2/2
✓ Branch 0 taken 18501702 times.
✓ Branch 1 taken 804 times.
18502506 for(int32_t i=0; i<tiles_used; ++i)
19379 {
19380 18501702 byte format=tf4Bit;
19381 18501702 memset(temp_tile, 0, tilesize(tf32Bit));
19382
19383
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 15516246 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18501702 if((version>0x211)||((version==0x211)&&(build>4)))
19384 {
19385
1/2
✓ Branch 0 taken 15516246 times.
✗ Branch 1 not taken.
15516246 if(!p_getc(&format,f))
19386 {
19387 delete[] temp_tile;
19388 return qe_invalid;
19389 }
19390 15516246 }
19391
4/4
✓ Branch 0 taken 7573472 times.
✓ Branch 1 taken 10928230 times.
✓ Branch 2 taken 3466558 times.
✓ Branch 3 taken 4106914 times.
18501702 if(section_version > 2 && !format)
19392 {
19393 4106914 reset_tile(buf,start_tile+i,tf4Bit);
19394 4106914 continue;
19395 }
19396
19397
2/2
✓ Branch 0 taken 13902064 times.
✓ Branch 1 taken 492724 times.
14394788 int size = format == tf4Bit ? 128 : tilesize(format);
19398
1/2
✓ Branch 0 taken 14394788 times.
✗ Branch 1 not taken.
14394788 if(!pfread(temp_tile,size,f))
19399 {
19400 delete[] temp_tile;
19401 return qe_invalid;
19402 }
19403
19404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14394788 times.
14394788 if (should_skip)
19405 continue;
19406
19407 14394788 buf[start_tile+i].format=format;
19408
19409
2/2
✓ Branch 0 taken 14190903 times.
✓ Branch 1 taken 203885 times.
14394788 if(buf[start_tile+i].data)
19410 {
19411 14190903 free(buf[start_tile+i].data);
19412 14190903 buf[start_tile+i].data=NULL;
19413 14190903 }
19414
19415 14394788 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19416
19417
2/2
✓ Branch 0 taken 13902064 times.
✓ Branch 1 taken 492724 times.
14394788 if (format == tf4Bit)
19418 {
19419 byte temp[256];
19420 13902064 byte *si = temp_tile + 128;
19421 13902064 byte *di = temp + 256;
19422
19423
2/2
✓ Branch 0 taken 1779464192 times.
✓ Branch 1 taken 13902064 times.
1793366256 for(int i=127; i>=0; --i)
19424 {
19425 1779464192 (*(--di)) = (*(--si)) >> 4;
19426 1779464192 (*(--di)) = (*si) & 15;
19427 1779464192 }
19428
19429 13902064 memcpy(buf[start_tile+i].data,temp,256);
19430 13902064 }
19431 else
19432 {
19433 492724 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19434 }
19435 14394788 }
19436 }
19437
19438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (should_skip)
19439 return 0;
19440
19441
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
804 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19442 {
19443
2/2
✓ Branch 0 taken 90281880 times.
✓ Branch 1 taken 606 times.
90282486 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19444 {
19445
19446 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19447 90281880 reset_tile(buf,q,tf4Bit);
19448
19449
19450 /*
19451
19452 byte tempbyte;
19453 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19454 {
19455 tempbyte=buf[ZC250MAXTILES-1].data[i];
19456 buf[q].data[i] = tempbyte;
19457 }
19458 //int32_t temp = tempbyte=buf[130].data[i];
19459 //buf[q].data = buf[ZC250MAXTILES-1].data;
19460 */
19461 //reset_tile(buf,q,tf4Bit);
19462 90281880 }
19463
19464 606 }
19465
19466
4/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 198 times.
804 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19467 {
19468
2/2
✓ Branch 0 taken 30244486 times.
✓ Branch 1 taken 606 times.
30245092 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19469 {
19470 30244486 reset_tile(buf,i,tf4Bit);
19471 30244486 }
19472 606 }
19473 else
19474 {
19475
2/2
✓ Branch 0 taken 34323812 times.
✓ Branch 1 taken 198 times.
34324010 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19476 {
19477 34323812 reset_tile(buf,i,tf4Bit);
19478 34323812 }
19479 }
19480
19481
5/6
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 780 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
804 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19482 {
19483
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19484 {
19485 byte tempbyte;
19486 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19487
19488
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19489 {
19490 1536 tempbyte=buf[23].data[i];
19491 1536 buf[23].data[i]=buf[24].data[i];
19492 1536 buf[24].data[i]=buf[25].data[i];
19493 1536 buf[25].data[i]=buf[26].data[i];
19494 1536 buf[26].data[i]=tempbyte;
19495 1536 }
19496 //swim tiles are out of order, too, but nobody cared? -Z
19497
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19498 {
19499 1536 tempbyte=buf[floattile+11].data[i];
19500 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19501 1536 buf[floattile+12].data[i]=tempbyte;
19502 1536 }
19503 6 }
19504 24 }
19505
19506
3/6
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19507 {
19508
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19509 {
19510 byte tempbyte;
19511
19512
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19513 {
19514 5632 tempbyte=buf[130].data[i];
19515 5632 buf[130].data[i]=buf[132].data[i];
19516 5632 buf[132].data[i]=tempbyte;
19517
19518 5632 tempbyte=buf[131].data[i];
19519 5632 buf[131].data[i]=buf[133].data[i];
19520 5632 buf[133].data[i]=tempbyte;
19521 5632 }
19522 22 }
19523 83 }
19524
19525 804 al_trace("Registering blank tiles\n");
19526 804 register_blank_tiles();
19527
19528 //memset(temp_tile, 0, tilesize(tf32Bit));
19529
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 delete[] temp_tile;
19530 804 temp_tile=NULL;
19531 804 return 0;
19532 804 }
19533
19534 480 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19535 {
19536
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19537
19538 static byte fake_midi_flags[32];
19539
19540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19541 int32_t dummy;
19542 word dummy2;
19543 // zcmidi_ temp_midi;
19544 int32_t tunes_to_read;
19545 480 int32_t tune_count=0;
19546 480 word section_version=0;
19547 480 zctune temp;
19548
19549
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version < 0x193)
19550 {
19551 // mf=Header->data_flags+ZQ_MIDIS2;
19552
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19553 {
19554 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19555 22 }
19556 else
19557 {
19558 1 tunes_to_read=MAXCUSTOMTUNES;
19559 }
19560 23 }
19561 else
19562 {
19563 //section version info
19564
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&section_version,f))
19565 {
19566 return qe_invalid;
19567 }
19568
19569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (!should_skip)
19570 457 FFCore.quest_format[vMIDIs] = section_version;
19571
19572
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy2,f))
19573 {
19574 return qe_invalid;
19575 }
19576
19577 //section size
19578
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
19579 {
19580 return qe_invalid;
19581 }
19582
19583 //finally... section data
19584
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!pfread(midi_flags,sizeof(midi_flags),f))
19585 {
19586 return qe_invalid;
19587 }
19588
19589 457 tunes_to_read=MAXCUSTOMTUNES;
19590 }
19591
19592
2/2
✓ Branch 0 taken 120960 times.
✓ Branch 1 taken 480 times.
121440 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19593 {
19594
2/2
✓ Branch 0 taken 10210 times.
✓ Branch 1 taken 110750 times.
120960 if(get_bit(mf, i))
19595 {
19596 10210 ++tune_count;
19597 10210 }
19598 120960 }
19599
19600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (!should_skip)
19601 480 reset_tunes(tunes); //reset_midis(midis);
19602
19603
2/2
✓ Branch 0 taken 116120 times.
✓ Branch 1 taken 480 times.
116600 for(int32_t i=0; i<tunes_to_read; i++)
19604 {
19605 116120 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19606
19607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116120 times.
116120 if (!should_skip)
19608 116120 tunes[i].reset(); // reset_midi(midis+i);
19609
19610
2/2
✓ Branch 0 taken 105910 times.
✓ Branch 1 taken 10210 times.
116120 if(get_bit(mf,i))
19611 {
19612
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version < 4)
19613 {
19614
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19615 {
19616 return qe_invalid;
19617 }
19618 2663 }
19619 else
19620 {
19621
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19622 {
19623 return qe_invalid;
19624 }
19625 }
19626
19627
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.start,f))
19628 {
19629 return qe_invalid;
19630 }
19631
19632
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.loop_start,f))
19633 {
19634 return qe_invalid;
19635 }
19636
19637
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.loop_end,f))
19638 {
19639 return qe_invalid;
19640 }
19641
19642
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetw(&temp.loop,f))
19643 {
19644 return qe_invalid;
19645 }
19646
19647
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetw(&temp.volume,f))
19648 {
19649 return qe_invalid;
19650 }
19651
19652
2/2
✓ Branch 0 taken 9961 times.
✓ Branch 1 taken 249 times.
10210 if(Header->zelda_version < 0x193)
19653 {
19654
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19655 {
19656 return qe_invalid;
19657 }
19658 249 }
19659
19660
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version >= 3)
19661 {
19662
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19663 {
19664 return qe_invalid;
19665 }
19666 7547 }
19667
19668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10210 times.
10210 if (!should_skip)
19669 10210 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19670
19671
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19672 {
19673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19674 {
19675 if (read_midi(f)==NULL)
19676 {
19677 return qe_invalid;
19678 }
19679
19680 continue;
19681 }
19682
19683 // old format - a midi is a midi
19684
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19685 {
19686 return qe_invalid;
19687 }
19688 2663 }
19689 else
19690 {
19691 byte format;
19692
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!pfread(&format,sizeof(format),f))
19693 {
19694 return qe_invalid;
19695 }
19696
19697 // MIDI is the only format saved here.
19698 // Never did more than MIDI for a zctune, and no plans to now.
19699
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if (format != MFORMAT_MIDI)
19700 {
19701 return qe_invalid;
19702 }
19703
19704 7547 tunes[i].data = read_midi(f);
19705
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if (!tunes[i].data)
19706 {
19707 return qe_invalid;
19708 }
19709 }
19710 10210 }
19711 116120 }
19712
19713 480 return 0;
19714 480 }
19715
19716 480 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19717 {
19718
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19719
19720 int32_t dummy;
19721 ZCHEATS tempzcheats;
19722 480 char temp_use_cheats=1;
19723 480 memset(&tempzcheats, 0, sizeof(tempzcheats));
19724 480 word s_version = 0;
19725
19726
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version > 0x192)
19727 {
19728 //section version info
19729
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
19730 {
19731 return qe_invalid;
19732 }
19733
19734 457 FFCore.quest_format[vCheats] = s_version;
19735
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy,f))
19736 {
19737 return qe_invalid;
19738 }
19739
19740 //section size
19741
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
19742 {
19743 return qe_invalid;
19744 }
19745
19746 //finally... section data
19747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(!p_getc(&temp_use_cheats,f))
19748 {
19749 return qe_invalid;
19750 }
19751 457 }
19752
19753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(Header->data_flags[ZQ_CHEATS2])
19754 {
19755
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_igetl(&tempzcheats.flags,f))
19756 {
19757 return qe_invalid;
19758 }
19759
19760
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19761 {
19762 return qe_invalid;
19763 }
19764 480 }
19765
19766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (should_skip)
19767 return 0;
19768
19769 480 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19770 480 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19771
19772 480 return 0;
19773 480 }
19774
19775 299 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19776 {
19777
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
299 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19778
19779 byte padding, tempbyte;
19780
19781 // Legacy item properties (now integrated into itemdata)
19782 byte sword_hearts[4];
19783 byte beam_hearts[4];
19784 299 byte beam_percent=0;
19785 word beam_power[4];
19786 299 byte hookshot_length=99;
19787 299 byte hookshot_links=100;
19788 299 byte longshot_length=99;
19789 299 byte longshot_links=100;
19790 299 byte moving_fairy_hearts=3;
19791 299 byte moving_fairy_heart_percent=0;
19792 299 byte stationary_fairy_hearts=3;
19793 299 byte stationary_fairy_heart_percent=0;
19794 299 byte moving_fairy_magic=0;
19795 299 byte moving_fairy_magic_percent=0;
19796 299 byte stationary_fairy_magic=0;
19797 299 byte stationary_fairy_magic_percent=0;
19798 299 byte blue_potion_hearts=100;
19799 299 byte blue_potion_heart_percent=1;
19800 299 byte red_potion_hearts=100;
19801 299 byte red_potion_heart_percent=1;
19802 299 byte blue_potion_magic=100;
19803 299 byte blue_potion_magic_percent=1;
19804 299 byte red_potion_magic=100;
19805 299 byte red_potion_magic_percent=1;
19806
19807 299 byte bomb_ratio = 4;
19808
19809 299 subscr_mode = 0;
19810
19811 /* HIGHLY UNORTHODOX UPDATING THING, by L
19812 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19813 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19814 * changing from 13 to 14.
19815 */
19816
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 14)
19817 82 fixpolsvoice=true;
19818
19819 /* End highly unorthodox updating thing */
19820
19821
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 111 times.
299 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19822 111 temp_zinit.jump_hero_layer_threshold=0;
19823
19824
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
299 if(s_version >= 10)
19825 {
19826 char temp;
19827
19828 //new-style items
19829
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 217 times.
55769 for(int32_t j=0; j<256; j++)
19830 {
19831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55552 times.
55552 if(!p_getc(&temp,f))
19832 return qe_invalid;
19833
19834 55552 temp_zinit.set_item(j, temp != 0);
19835 55552 }
19836 217 }
19837
19838
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19839 {
19840 char temp;
19841
19842 //finally... section data
19843
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
19844 //new only
19845
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19846 {
19847 //OLD-style items... sigh
19848
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 60 times.
277 if(s_version < 10)
19849 {
19850
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19851 {
19852 return qe_invalid;
19853 }
19854
19855 60 temp_zinit.set_item(iRaft, temp != 0);
19856
19857
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19858 {
19859 return qe_invalid;
19860 }
19861
19862 60 temp_zinit.set_item(iLadder, temp != 0);
19863
19864
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19865 {
19866 return qe_invalid;
19867 }
19868
19869 60 temp_zinit.set_item(iBook, temp != 0);
19870
19871
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19872 {
19873 return qe_invalid;
19874 }
19875
19876 60 temp_zinit.set_item(iMKey, temp != 0);
19877
19878
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19879 {
19880 return qe_invalid;
19881 }
19882
19883 60 temp_zinit.set_item(iFlippers, temp != 0);
19884
19885
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19886 {
19887 return qe_invalid;
19888 }
19889
19890 60 temp_zinit.set_item(iBoots, temp != 0);
19891 60 }
19892 277 }
19893
19894
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
19895 {
19896 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19897
19898
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19899 {
19900 return qe_invalid;
19901 }
19902
19903
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19904 {
19905 return qe_invalid;
19906 }
19907
19908
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19909 {
19910 return qe_invalid;
19911 }
19912
19913
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19914 {
19915 return qe_invalid;
19916 }
19917
19918
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19919 {
19920 return qe_invalid;
19921 }
19922
19923
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19924 {
19925 return qe_invalid;
19926 }
19927
19928
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19929 {
19930 return qe_invalid;
19931 }
19932
19933 //old only
19934
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19935 {
19936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19938
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19943 4 }
19944
19945 //rings start at level 2... wtf
19946 //account for this -DD
19947 64 tempring <<= 1;
19948 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19949 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19950 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19951 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19952 //bracelet ALSO starts at level 2 :-( -DD
19953 64 tempbracelet<<=1;
19954 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19955 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19956 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19957
19958 //new only
19959
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19960 {
19961
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19962 {
19963
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19964 {
19965 return qe_invalid;
19966 }
19967 32 }
19968 1 }
19969
19970 char tempcandle, tempboomerang, temparrow, tempwhistle;
19971
19972
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19973 {
19974 return qe_invalid;
19975 }
19976
19977
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19978 {
19979 return qe_invalid;
19980 }
19981
19982
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19983 {
19984 return qe_invalid;
19985 }
19986
19987
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19988 {
19989 return qe_invalid;
19990 }
19991
19992 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19993
19994
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19995 {
19996 return qe_invalid;
19997 }
19998
19999 //old only
20000
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20001 {
20002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
20003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
20004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
20005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
20006 4 }
20007
20008 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
20009 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
20010 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
20011 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
20012 //What about the potion...?
20013
20014 64 }
20015
20016
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20017 {
20018 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
20019 //to jab out my eye...
20020
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20021 return qe_invalid;
20022 264 temp_zinit.counter[crBOMBS] = padding;
20023
20024
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20025 return qe_invalid;
20026 264 temp_zinit.counter[crSBOMBS] = padding;
20027 264 }
20028
20029 //Back to more OLD item code
20030
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20031 {
20032
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
20033 //new only
20034
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20035 {
20036
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20037 {
20038 return qe_invalid;
20039 }
20040
20041 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
20042
20043
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20044 {
20045 return qe_invalid;
20046 }
20047
20048 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
20049
20050
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20051 {
20052 return qe_invalid;
20053 }
20054
20055 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
20056
20057
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20058 {
20059 return qe_invalid;
20060 }
20061
20062 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
20063
20064
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20065 {
20066 return qe_invalid;
20067 }
20068
20069 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
20070
20071
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20072 {
20073 return qe_invalid;
20074 }
20075
20076 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
20077
20078
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20079 {
20080 return qe_invalid;
20081 }
20082
20083 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
20084
20085
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20086 {
20087 return qe_invalid;
20088 }
20089
20090 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
20091
20092
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20093 {
20094 return qe_invalid;
20095 }
20096
20097 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20098
20099
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20100 {
20101 return qe_invalid;
20102 }
20103
20104
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
20105 {
20106
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20107 {
20108
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20109 {
20110 return qe_invalid;
20111 }
20112 32 }
20113 1 }
20114 60 }
20115 64 }
20116
20117 //old only
20118
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20119 {
20120 byte equipment, tmpitm; //bit flags
20121
20122
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
20123 {
20124 return qe_invalid;
20125 }
20126
20127 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
20128 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
20129 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
20130 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
20131 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
20132 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
20133
20134
20135
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
20136 {
20137 return qe_invalid;
20138 }
20139
20140 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
20141 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
20142 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
20143 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
20144 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
20145 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
20146 4 }
20147
20148
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20149 return qe_invalid;
20150 281 temp_zinit.mcounter[crLIFE] = tempbyte;
20151
20152
20153
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20154 {
20155 byte temphp;
20156
20157
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20158 {
20159 return qe_invalid;
20160 }
20161
20162 64 temp_zinit.counter[crLIFE]=temphp;
20163
20164
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20165 {
20166 return qe_invalid;
20167 }
20168
20169 64 temp_zinit.cont_heart=temphp;
20170 64 }
20171 else
20172 {
20173
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
20174 {
20175 return qe_invalid;
20176 }
20177
20178
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.cont_heart,f))
20179 {
20180 return qe_invalid;
20181 }
20182 }
20183
20184
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.hcp,f))
20185 {
20186 return qe_invalid;
20187 }
20188
20189
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version >= 14)
20190 {
20191
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20192 {
20193 return qe_invalid;
20194 }
20195
20196
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(s_version<16) // July 2007
20197 {
20198 if(get_qr(qr_BRANGPICKUP+1))
20199 temp_zinit.hcp_per_hc = 0xFF;
20200
20201 //Dispose of legacy rule
20202 set_qr(qr_BRANGPICKUP+1, 0);
20203 }
20204 217 }
20205
20206
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20207 {
20208
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20209 return qe_invalid;
20210 264 temp_zinit.mcounter[crBOMBS] = padding;
20211 264 }
20212
20213
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.counter[crKEYS],f))
20214 {
20215 return qe_invalid;
20216 }
20217
20218
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
20219 {
20220 return qe_invalid;
20221 }
20222
20223
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20224 return qe_invalid;
20225
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 281 times.
2529 for(int q = 0; q < 8; ++q)
20226
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1744 times.
2248 SETFLAG(temp_zinit.litems[q+1], (1 << li_mcguffin), get_bitl(tempbyte, q));
20227
20228 281 int level_count = 32;
20229
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
281 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20230 217 level_count = 64;
20231 byte tmp_map[64];
20232 byte tmp_compass[64];
20233
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20234
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_map[i],f))
20235 return qe_invalid;
20236
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20237
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_compass[i],f))
20238 return qe_invalid;
20239
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 281 times.
127769 for(int q = 0; q < level_count*8; ++q)
20240 {
20241
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 126692 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
20242
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 127479 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
20243 127488 }
20244
20245
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20246 //new only
20247
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20248 {
20249 byte tmp_boss_key[64];
20250
2/2
✓ Branch 0 taken 15808 times.
✓ Branch 1 taken 277 times.
16085 for(int32_t i=0; i<level_count; i++)
20251 {
20252
1/2
✓ Branch 0 taken 15808 times.
✗ Branch 1 not taken.
15808 if(!p_getc(&tmp_boss_key[i],f))
20253 {
20254 return qe_invalid;
20255 }
20256 15808 }
20257
2/2
✓ Branch 0 taken 126464 times.
✓ Branch 1 taken 277 times.
126741 for(int q = 0; q < level_count*8; ++q)
20258 {
20259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126464 times.
126464 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20260 126464 }
20261 277 }
20262
20263 byte tmpmisc[16];
20264
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 281 times.
4777 for(int32_t i=0; i<16; i++)
20265
1/2
✓ Branch 0 taken 4496 times.
✗ Branch 1 not taken.
4496 if(!p_getc(&tmpmisc[i],f))
20266 return qe_invalid;
20267 281 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
20268 281 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
20269 281 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
20270
20271
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
537 if(s_version < 15) for(int32_t i=0; i<4; i++)
20272
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
20273 64 return qe_invalid;
20274
20275
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_map,f))
20276 {
20277 return qe_invalid;
20278 }
20279
20280
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_screen,f))
20281 {
20282 return qe_invalid;
20283 }
20284
20285
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20286 {
20287 byte tempmp;
20288
20289
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20290 {
20291 return qe_invalid;
20292 }
20293
20294 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20295
20296
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20297 {
20298 return qe_invalid;
20299 }
20300
20301 64 temp_zinit.counter[crMAGIC]=tempmp;
20302 64 }
20303 else
20304 {
20305
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20306 {
20307 return qe_invalid;
20308 }
20309
20310
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20311 {
20312 return qe_invalid;
20313 }
20314 }
20315
20316
20317
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 15)
20318 {
20319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20320 {
20321 64 temp_zinit.mcounter[crMAGIC]*=32;
20322 64 temp_zinit.counter[crMAGIC]*=32;
20323 64 }
20324
20325
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20326 {
20327
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20328 {
20329 return qe_invalid;
20330 }
20331 256 }
20332
20333
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20334 {
20335 return qe_invalid;
20336 }
20337 64 }
20338 else
20339 {
20340
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.bomb_ratio,f))
20341 return qe_invalid;
20342
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(temp_zinit.bomb_ratio < 1)
20343 temp_zinit.bomb_ratio = 1;
20344 217 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20345 }
20346
20347
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 15)
20348 {
20349 byte tempbp;
20350
20351
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20352 {
20353
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20354 {
20355 return qe_invalid;
20356 }
20357
20358 256 beam_power[i]=tempbp;
20359 256 }
20360
20361
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20362 {
20363 return qe_invalid;
20364 }
20365
20366
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20367 {
20368 if(!p_getc(&hookshot_length,f))
20369 {
20370 return qe_invalid;
20371 }
20372
20373 if(!p_getc(&longshot_links,f))
20374 {
20375 return qe_invalid;
20376 }
20377
20378 if(!p_getc(&longshot_length,f))
20379 {
20380 return qe_invalid;
20381 }
20382 }
20383 64 }
20384
20385
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_x,f))
20386 {
20387 return qe_invalid;
20388 }
20389
20390
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_y,f))
20391 {
20392 return qe_invalid;
20393 }
20394
20395
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&subscr_mode,f))
20396 return qe_invalid;
20397
20398 //old only
20399
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20400 {
20401 byte tmp_boss_key[32];
20402
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20403 {
20404
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20405 {
20406 return qe_invalid;
20407 }
20408 128 }
20409
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20410 {
20411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20412 1024 }
20413 4 }
20414
20415
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
281 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20416 {
20417
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 217 times.
277 if(s_version <= 10)
20418 {
20419
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20420 {
20421 return qe_invalid;
20422 }
20423
20424 60 temp_zinit.start_dmap = (word)tempbyte;
20425 60 }
20426 else
20427 {
20428
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.start_dmap,f))
20429 {
20430 return qe_invalid;
20431 }
20432 }
20433
20434
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20435 {
20436 return qe_invalid;
20437 }
20438 277 }
20439
20440
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 200 times.
281 if(s_version>1 && s_version < 29)
20441 {
20442
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20443 return qe_invalid;
20444 200 temp_zinit.counter[crARROWS] = padding;
20445
20446
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20447 return qe_invalid;
20448 200 temp_zinit.mcounter[crARROWS] = padding;
20449 200 }
20450
20451
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>2)
20452 {
20453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(s_version <= 10)
20454 {
20455 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20456 {
20457 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20458 {
20459 return qe_invalid;
20460 }
20461 }
20462 }
20463 else
20464 {
20465
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 217 times.
111321 for(int32_t i=0; i<MAXLEVELS; i++)
20466 {
20467
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20468 {
20469 return qe_invalid;
20470 }
20471 111104 }
20472 }
20473 217 }
20474
20475
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>3)
20476 {
20477
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20478 {
20479 return qe_invalid;
20480 }
20481
20482
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20483 {
20484 return qe_invalid;
20485 }
20486
20487
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20488 {
20489 return qe_invalid;
20490 }
20491
20492
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20493 {
20494 return qe_invalid;
20495 }
20496
20497
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20498 {
20499 return qe_invalid;
20500 }
20501
20502
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20503 {
20504 return qe_invalid;
20505 }
20506
20507
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20508 {
20509 return qe_invalid;
20510 }
20511
20512
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_flags,f))
20513 {
20514 return qe_invalid;
20515 }
20516
20517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20519 217 }
20520
20521
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>4 && s_version<15)
20522 {
20523 if(!p_getc(&moving_fairy_hearts,f))
20524 {
20525 return qe_invalid;
20526 }
20527
20528 if(!p_getc(&moving_fairy_heart_percent,f))
20529 {
20530 return qe_invalid;
20531 }
20532 }
20533
20534
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>5 && s_version < 10)
20535 {
20536 if(!p_getc(&temp,f))
20537 {
20538 return qe_invalid;
20539 }
20540
20541 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20542 }
20543
20544
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>6 && s_version<15)
20545 {
20546 if(!p_getc(&stationary_fairy_hearts,f))
20547 {
20548 return qe_invalid;
20549 }
20550
20551 if(!p_getc(&stationary_fairy_heart_percent,f))
20552 {
20553 return qe_invalid;
20554 }
20555
20556 if(!p_getc(&moving_fairy_magic,f))
20557 {
20558 return qe_invalid;
20559 }
20560
20561 if(!p_getc(&moving_fairy_magic_percent,f))
20562 {
20563 return qe_invalid;
20564 }
20565
20566 if(!p_getc(&stationary_fairy_magic,f))
20567 {
20568 return qe_invalid;
20569 }
20570
20571 if(!p_getc(&stationary_fairy_magic_percent,f))
20572 {
20573 return qe_invalid;
20574 }
20575
20576 if(!p_getc(&blue_potion_hearts,f))
20577 {
20578 return qe_invalid;
20579 }
20580
20581 if(!p_getc(&blue_potion_heart_percent,f))
20582 {
20583 return qe_invalid;
20584 }
20585
20586 if(!p_getc(&red_potion_hearts,f))
20587 {
20588 return qe_invalid;
20589 }
20590
20591 if(!p_getc(&red_potion_heart_percent,f))
20592 {
20593 return qe_invalid;
20594 }
20595
20596 if(!p_getc(&blue_potion_magic,f))
20597 {
20598 return qe_invalid;
20599 }
20600
20601 if(!p_getc(&blue_potion_magic_percent,f))
20602 {
20603 return qe_invalid;
20604 }
20605
20606 if(!p_getc(&red_potion_magic,f))
20607 {
20608 return qe_invalid;
20609 }
20610
20611 if(!p_getc(&red_potion_magic_percent,f))
20612 {
20613 return qe_invalid;
20614 }
20615 }
20616
20617
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>6)
20618
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20619 return qe_invalid;
20620
20621
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>7)
20622 {
20623
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20624 {
20625 return qe_invalid;
20626 }
20627 217 }
20628
20629
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>8)
20630 {
20631
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20632 {
20633 return qe_invalid;
20634 }
20635
20636
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20637 {
20638 return qe_invalid;
20639 }
20640 217 }
20641
20642
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version>16)
20643 {
20644
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&tempbyte,f))
20645 {
20646 return qe_invalid;
20647 }
20648 217 temp_zinit.gravity = tempbyte*100;
20649
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.terminalv,f))
20650 {
20651 return qe_invalid;
20652 }
20653
20654
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_speed,f))
20655 {
20656 return qe_invalid;
20657 }
20658
20659
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20660 {
20661 return qe_invalid;
20662 }
20663
20664
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20665 {
20666 return qe_invalid;
20667 }
20668 217 }
20669
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20670 12 temp_zinit.msg_speed = 0;
20671
20672
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>17)
20673 {
20674
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20675 {
20676 return qe_invalid;
20677 }
20678 217 }
20679
20680 //expaned init data for larger values in 2.55
20681
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 17 times.
281 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20682 {
20683
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20684 {
20685 return qe_invalid;
20686 }
20687
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20688 {
20689 return qe_invalid;
20690 }
20691
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20692 {
20693 return qe_invalid;
20694 }
20695
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20696 {
20697 return qe_invalid;
20698 }
20699
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20700 {
20701 return qe_invalid;
20702 }
20703
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20704 {
20705 return qe_invalid;
20706 }
20707
20708 17 }
20709
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 20 )
20710 {
20711
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20712 {
20713 return qe_invalid;
20714 }
20715 17 }
20716 else
20717 {
20718 264 temp_zinit.heroStep = 150; //1.5 pixels per frame
20719 }
20720
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 21 )
20721 {
20722
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20723 {
20724 return qe_invalid;
20725 }
20726 17 }
20727 else
20728 {
20729 264 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20730 }
20731 //old only
20732
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20733 {
20734 byte items2;
20735
20736
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20737 {
20738 return qe_invalid;
20739 }
20740
20741 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20742 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20743 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20744 4 }
20745
20746
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5 times.
281 if(Header->zelda_version < 0x193)
20747 {
20748
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20749 {
20750
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20751 {
20752 return qe_invalid;
20753 }
20754 480 }
20755
20756 //new only
20757
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20758 {
20759
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20760 {
20761 return qe_invalid;
20762 }
20763
20764
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20765 {
20766 return qe_invalid;
20767 }
20768 1 }
20769 5 }
20770 281 }
20771
20772
3/6
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20773 {
20774 //temp_zinit.shield=i_smallshield;
20775 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20776
20777
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20778 82 temp_zinit.set_item(sshieldid, true);
20779 82 }
20780
20781
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20782 {
20783 18 temp_zinit.mcounter[crLIFE]=3;
20784 18 temp_zinit.counter[crLIFE]=3;
20785 18 temp_zinit.cont_heart=3;
20786 18 temp_zinit.mcounter[crBOMBS]=8;
20787 18 }
20788
20789
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20790 {
20791 18 sword_hearts[0]=0;
20792 18 sword_hearts[1]=5;
20793 18 sword_hearts[2]=12;
20794 18 sword_hearts[3]=21;
20795 18 }
20796
20797
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20798 {
20799 18 temp_zinit.last_map=0;
20800 18 temp_zinit.last_screen=0;
20801 18 }
20802
20803
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20804 {
20805 18 temp_zinit.mcounter[crMAGIC]=0;
20806 18 temp_zinit.counter[crMAGIC]=0;
20807 18 temp_zinit.magicdrainrate = 2;
20808 18 }
20809
20810
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20811 {
20812
20813
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20814 {
20815 72 beam_hearts[x]=100;
20816 72 }
20817
20818
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20819 {
20820 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20821 72 set_qr(qr_LENSHINTS+i,0);
20822 72 }
20823
20824
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20825 {
20826 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20827 72 }
20828
20829 18 set_qr(qr_HIDECARRIEDITEMS,0);
20830 18 hookshot_links=100;
20831 18 temp_zinit.msg_more_x=224;
20832 18 temp_zinit.msg_more_y=64;
20833 18 }
20834
20835 // Okay, let's put these legacy values into itemsbuf.
20836
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 15)
20837
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20838 {
20839
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20840 {
20841 case iFairyStill:
20842 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20843 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20844 82 itemsbuf[i].misc3 = 0;
20845
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20846
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20847 82 break;
20848
20849 case iFairyMoving:
20850 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20851 82 itemsbuf[i].misc2 = moving_fairy_magic;
20852 82 itemsbuf[i].misc3 = 50;
20853
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20854
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20855 82 break;
20856
20857 case iRPotion:
20858 82 itemsbuf[i].misc1 = red_potion_hearts;
20859 82 itemsbuf[i].misc2 = red_potion_magic;
20860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20862 82 break;
20863
20864 case iBPotion:
20865 82 itemsbuf[i].misc1 = blue_potion_hearts;
20866 82 itemsbuf[i].misc2 = blue_potion_magic;
20867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20869 82 break;
20870
20871 case iSword:
20872 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20873 82 itemsbuf[i].misc1 = beam_hearts[0];
20874 82 itemsbuf[i].misc2 = beam_power[0];
20875 // It seems that item_flag1 was already added by reset_itembuf()...
20876 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20877 82 break;
20878
20879 case iWSword:
20880 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20881 82 itemsbuf[i].misc1 = beam_hearts[1];
20882 82 itemsbuf[i].misc2 = beam_power[1];
20883 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20884 82 break;
20885
20886 case iMSword:
20887 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20888 82 itemsbuf[i].misc1 = beam_hearts[2];
20889 82 itemsbuf[i].misc2 = beam_power[2];
20890 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20891 82 break;
20892
20893 case iXSword:
20894 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20895 82 itemsbuf[i].misc1 = beam_hearts[3];
20896 82 itemsbuf[i].misc2 = beam_power[3];
20897 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20898 82 break;
20899
20900 case iHookshot:
20901 82 itemsbuf[i].misc1 = hookshot_length;
20902 82 itemsbuf[i].misc2 = hookshot_links;
20903 82 break;
20904
20905 case iLongshot:
20906 82 itemsbuf[i].misc1 = longshot_length;
20907 82 itemsbuf[i].misc2 = longshot_links;
20908 82 break;
20909 }
20910 21074 }
20911
20912
6/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20913 {
20914 //was new subscreen rule
20915 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20916 22 set_qr(qr_FREEFORM,0);
20917 22 }
20918
20919
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20920 {
20921 23 temp_zinit.start_dmap=0;
20922 23 }
20923
20924
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20925 {
20926 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20927 23 }
20928
20929
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
299 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20930 {
20931 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20932 temp_zinit.mcounter[crMONEY]=999;
20933 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20934 }
20935
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20936 {
20937 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20938 6 temp_zinit.mcounter[crBOMBS] = 8;
20939 6 }
20940 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20941 //time to ensure that we port all new values properly:
20942
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(Header->zelda_version < 0x250)
20943 {
20944
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20945 82 }
20946
20947
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 21)
20948 {
20949
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20950 {
20951 return qe_invalid;
20952 }
20953
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
20954 {
20955 return qe_invalid;
20956 }
20957
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20958 {
20959 return qe_invalid;
20960 }
20961
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20962 {
20963 return qe_invalid;
20964 }
20965 17 }
20966 else
20967 {
20968 282 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20969 282 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20970 282 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20971 282 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20972 }
20973
20974
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 22)
20975 {
20976
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
20978 return qe_invalid;
20979
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
20981 return qe_invalid;
20982 17 }
20983
20984
20985
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 23)
20986 {
20987
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
20988 {
20989 return qe_invalid;
20990 }
20991
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
20992 {
20993 return qe_invalid;
20994 }
20995
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
20996 {
20997 return qe_invalid;
20998 }
20999
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
21000 {
21001 return qe_invalid;
21002 }
21003
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
21004 {
21005 return qe_invalid;
21006 }
21007 17 }
21008 else
21009 {
21010 282 temp_zinit.dither_type = 0;
21011 282 temp_zinit.dither_arg = 0;
21012 282 temp_zinit.dither_percent = 20;
21013 282 temp_zinit.def_lightrad = 24;
21014 282 temp_zinit.transdark_percent = 0;
21015 }
21016
21017
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 24)
21018 {
21019
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
21020 {
21021 return qe_invalid;
21022 }
21023 17 }
21024 else
21025 {
21026 282 temp_zinit.darkcol = BLACK;
21027 }
21028
21029
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 25)
21030 {
21031
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
21032 {
21033 return qe_invalid;
21034 }
21035
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
21036 {
21037 return qe_invalid;
21038 }
21039 17 }
21040
21041
21042
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 26)
21043 {
21044
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21045 {
21046 return qe_invalid;
21047 }
21048
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21049 {
21050 return qe_invalid;
21051 }
21052
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21053 {
21054 return qe_invalid;
21055 }
21056 17 }
21057 else
21058 {
21059 282 temp_zinit.heroSideswimUpStep = 150;
21060 282 temp_zinit.heroSideswimSideStep = 100;
21061 282 temp_zinit.heroSideswimDownStep = 75;
21062 }
21063
21064
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 27)
21065 {
21066
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21067 {
21068 return qe_invalid;
21069 }
21070 17 }
21071 else
21072 {
21073 282 temp_zinit.exitWaterJump = 0;
21074 }
21075
21076
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 29)
21077 {
21078
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21079 {
21080 return qe_invalid;
21081 }
21082 17 }
21083 else
21084 {
21085 282 temp_zinit.bunny_ltm = 0;
21086 }
21087
21088
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 30)
21089 {
21090
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
21091 {
21092 return qe_invalid;
21093 }
21094 17 }
21095 else
21096 {
21097 282 temp_zinit.switchhookstyle = 1;
21098 }
21099
21100
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 31)
21101 {
21102
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
21103 {
21104 return qe_invalid;
21105 }
21106 17 }
21107
21108 299 temp_zinit.clear_genscript();
21109
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 12 times.
299 if(s_version > 32)
21110 {
21111 12 word numgenscript = 0;
21112
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
21113 return qe_invalid;
21114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
21115 return qe_invalid;
21116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
21117 {
21118 if(!p_getc(&tempbyte,f))
21119 return qe_invalid;
21120 if(!(tempbyte&2))
21121 continue;
21122 temp_zinit.gen_doscript.set(q, tempbyte&1);
21123 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
21124 return qe_invalid;
21125 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
21126 return qe_invalid;
21127 for(auto p = 0; p < 8; ++p)
21128 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
21129 return qe_invalid;
21130 dword sz;
21131 if(!p_igetl(&sz,f))
21132 return qe_invalid;
21133 temp_zinit.gen_data[q].resize(sz);
21134 std::vector<int32_t> dummy;
21135 if(!p_getlvec(&dummy,f))
21136 return qe_invalid;
21137 temp_zinit.gen_data[q] = dummy;
21138 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
21139 return qe_invalid;
21140 }
21141 12 }
21142
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(s_version > 33)
21143 {
21144
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21145 return qe_invalid;
21146
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
21147 return qe_invalid;
21148 6 }
21149
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(s_version > 34)
21150 {
21151 uint32_t num_used_mapscr_data;
21152 if(!p_igetl(&num_used_mapscr_data,f))
21153 return qe_invalid;
21154 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
21155 {
21156 uint32_t sz;
21157 if(!p_igetl(&sz,f))
21158 return qe_invalid;
21159 temp_zinit.screen_data[q].resize(sz);
21160 if(sz)
21161 {
21162 std::vector<int32_t> dummy;
21163 if(!p_getlvec(&dummy,f))
21164 return qe_invalid;
21165 temp_zinit.screen_data[q] = dummy;
21166 }
21167 }
21168 }
21169
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if (s_version > 35)
21170 if(!p_igetzf(&temp_zinit.shove_offset,f))
21171 return qe_invalid;
21172
21173 299 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
21174 299 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
21175
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 110 times.
299 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
21176 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
21177
21178 299 return 0;
21179 299 }
21180 480 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
21181 {
21182 480 zinitdata temp_zinit = {};
21183
21184
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
21185
21186 int32_t dummy;
21187 480 word s_version=0;
21188 byte padding;
21189
21190
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 if(Header->zelda_version > 0x192)
21191 {
21192
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
21193 return qe_invalid;
21194 457 FFCore.quest_format[vInitData] = s_version;
21195
21196
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
21197 return qe_invalid;
21198
21199 //section size
21200
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
21201 return qe_invalid;
21202 457 }
21203
21204
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 181 times.
480 if(s_version < 37)
21205 {
21206
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
21207 return ret;
21208 299 }
21209 else
21210 {
21211 181 subscr_mode = ssdtMAX;
21212
2/2
✓ Branch 0 taken 5792 times.
✓ Branch 1 taken 181 times.
5973 for(int q = 0; q < MAXITEMS/8; ++q)
21213
2/4
✓ Branch 0 taken 5792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5792 times.
5792 if(!p_getc(&temp_zinit.items[q], f))
21214 return qe_invalid;
21215
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 46 times.
181 if(s_version >= 42)
21216 {
21217
2/2
✓ Branch 0 taken 69120 times.
✓ Branch 1 taken 135 times.
69255 for(int q = 0; q < MAXLEVELS; ++q)
21218 {
21219
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 38912 times.
69120 if (s_version >= 44)
21220 {
21221
2/4
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38912 times.
38912 if(!p_igetw(&temp_zinit.litems[q], f))
21222 return qe_invalid;
21223 38912 }
21224 else
21225 {
21226
2/4
✓ Branch 0 taken 30208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30208 times.
30208 if(!p_getc(&padding, f))
21227 return qe_invalid;
21228 30208 temp_zinit.litems[q] = word(padding);
21229 }
21230 69120 }
21231 135 }
21232 else
21233 {
21234 byte tmp_map[MAXLEVELS/8];
21235 byte tmp_compass[MAXLEVELS/8];
21236 byte tmp_boss_key[MAXLEVELS/8];
21237 byte tmp_mcguffin[MAXLEVELS/8];
21238
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 46 times.
2990 for(int q = 0; q < MAXLEVELS/8; ++q)
21239 {
21240
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_map[q], f))
21241 return qe_invalid;
21242
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_compass[q], f))
21243 return qe_invalid;
21244
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_boss_key[q], f))
21245 return qe_invalid;
21246
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_mcguffin[q], f))
21247 return qe_invalid;
21248 2944 }
21249
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 46 times.
23598 for(int q = 0; q < MAXLEVELS; ++q)
21250 {
21251
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
21252
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 23532 times.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
21253
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
21254
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 23408 times.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_mcguffin), get_bit(tmp_mcguffin, q));
21255 23552 }
21256 }
21257
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbvec(&temp_zinit.level_keys, f))
21258 return qe_invalid;
21259 byte num_counters;
21260
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&num_counters,f))
21261 return qe_invalid;
21262
2/2
✓ Branch 0 taken 19367 times.
✓ Branch 1 taken 181 times.
19548 for(int q = 0; q < num_counters; ++q)
21263
2/4
✓ Branch 0 taken 19367 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19367 times.
19367 if(!p_igetw(&temp_zinit.counter[q],f))
21264 return qe_invalid;
21265
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 19367 times.
19548 for(int q = 0; q < num_counters; ++q)
21266
2/4
✓ Branch 0 taken 19367 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19367 times.
19367 if(!p_igetw(&temp_zinit.mcounter[q],f))
21267 return qe_invalid;
21268
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.bomb_ratio,f))
21269 return qe_invalid;
21270
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hcp,f))
21271 return qe_invalid;
21272
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hcp_per_hc,f))
21273 return qe_invalid;
21274
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.cont_heart,f))
21275 return qe_invalid;
21276
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hp_per_heart,f))
21277 return qe_invalid;
21278
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.magic_per_block,f))
21279 return qe_invalid;
21280
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21281 return qe_invalid;
21282
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21283 return qe_invalid;
21284
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.dither_type,f))
21285 return qe_invalid;
21286
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.dither_arg,f))
21287 return qe_invalid;
21288
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.dither_percent,f))
21289 return qe_invalid;
21290
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.def_lightrad,f))
21291 return qe_invalid;
21292
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.transdark_percent,f))
21293 return qe_invalid;
21294
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.darkcol,f))
21295 return qe_invalid;
21296
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21297 return qe_invalid;
21298
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21299 return qe_invalid;
21300
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21301 return qe_invalid;
21302
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21303 return qe_invalid;
21304
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21305 return qe_invalid;
21306
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21307 return qe_invalid;
21308
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21309 return qe_invalid;
21310
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_flags,f))
21311 return qe_invalid;
21312
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbitstr(&temp_zinit.flags,f))
21313 return qe_invalid;
21314
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.last_map,f))
21315 return qe_invalid;
21316
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.last_screen,f))
21317 return qe_invalid;
21318
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_more_x,f))
21319 return qe_invalid;
21320
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_more_y,f))
21321 return qe_invalid;
21322
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21323 return qe_invalid;
21324
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_speed,f))
21325 return qe_invalid;
21326
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.gravity,f))
21327 return qe_invalid;
21328
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.swimgravity,f))
21329 return qe_invalid;
21330
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.terminalv,f))
21331 return qe_invalid;
21332
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21333 return qe_invalid;
21334
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21335 return qe_invalid;
21336
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_swim_div,f))
21337 return qe_invalid;
21338
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21339 return qe_invalid;
21340
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21341 return qe_invalid;
21342
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21343 return qe_invalid;
21344
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21345 return qe_invalid;
21346
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroStep,f))
21347 return qe_invalid;
21348
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21349 return qe_invalid;
21350
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21351 return qe_invalid;
21352
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21353 return qe_invalid;
21354
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.start_dmap,f))
21355 return qe_invalid;
21356
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21357 return qe_invalid;
21358
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.switchhookstyle,f))
21359 return qe_invalid;
21360
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.magicdrainrate,f))
21361 return qe_invalid;
21362
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetzf(&temp_zinit.shove_offset,f))
21363 return qe_invalid;
21364
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21365 return qe_invalid;
21366
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21367 return qe_invalid;
21368
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21369 return qe_invalid;
21370
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_getbmap(&temp_zinit.gen_initd, f))
21371 return qe_invalid;
21372
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21373 return qe_invalid;
21374
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.gen_data, f))
21375 return qe_invalid;
21376
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.screen_data, f))
21377 return qe_invalid;
21378
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if (s_version >= 38)
21379 {
21380
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21381 return qe_invalid;
21382
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21383 return qe_invalid;
21384
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21385 return qe_invalid;
21386 181 }
21387
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
181 if(s_version >= 39)
21388
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_igetzf(&temp_zinit.air_drag, f))
21389 return qe_invalid;
21390
21391 // TODO: this first branch can likely be removed, as it only fixes an issues
21392 // that existed for a handful of temporary z3 builds (and active users of that
21393 // fork would have been updating often, beyond s_version 40).
21394
3/4
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153 times.
181 if (Header->is_z3 && s_version == 40)
21395 {
21396 if(!p_getc(&temp_zinit.region_mapping, f))
21397 return qe_invalid;
21398 }
21399 else
21400 {
21401
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
181 if(s_version >= 40)
21402 {
21403
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21404 return qe_invalid;
21405
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_igetw(&temp_zinit.light_wave_size, f))
21406 return qe_invalid;
21407 153 }
21408
21409
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
181 if(s_version >= 41)
21410 {
21411
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_getc(&temp_zinit.region_mapping, f))
21412 return qe_invalid;
21413 153 }
21414 }
21415
21416
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 129 times.
181 if(s_version >= 43)
21417
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21418
2/4
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33024 times.
✗ Branch 3 not taken.
33024 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21419 129 return qe_invalid;
21420
21421
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 105 times.
181 if(s_version >= 44)
21422
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if (!p_getbvec(&temp_zinit.lvlswitches, f))
21423 return qe_invalid;
21424
21425
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 105 times.
181 if (s_version >= 45)
21426 {
21427
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if (!p_igetw(&temp_zinit.item_spawn_flicker, f))
21428 return qe_invalid;
21429
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if (!p_igetw(&temp_zinit.item_timeout_dur, f))
21430 return qe_invalid;
21431
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if (!p_igetw(&temp_zinit.item_timeout_flicker, f))
21432 return qe_invalid;
21433
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if (!p_getc(&temp_zinit.item_flicker_speed, f))
21434 return qe_invalid;
21435 76 }
21436
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 76 times.
181 if(s_version >= 46)
21437 {
21438
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 76 times.
456 for(int q = 0; q < SPRITE_THRESHOLD_MAX; ++q)
21439
2/4
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
380 if(!p_igetw(&temp_zinit.sprite_z_thresholds[q], f))
21440 return qe_invalid;
21441 76 }
21442 }
21443
21444
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 404 times.
480 if(s_version < 46)
21445 {
21446 404 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_GROUND] = temp_zinit.jump_hero_layer_threshold;
21447 404 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_3] = temp_zinit.jump_hero_layer_threshold;
21448 404 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_4] = temp_zinit.jump_hero_layer_threshold;
21449 404 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_OVERHEAD] = word(-1);
21450 404 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_5] = word(-1);
21451 404 }
21452
21453
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if (should_skip)
21454 return 0;
21455
21456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(loading_tileset_flags & TILESET_CLEARMAPS)
21457 {
21458 temp_zinit.last_map = 0;
21459 temp_zinit.last_screen = 0;
21460 temp_zinit.screen_data.clear();
21461 }
21462
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 temp_zinit.normalize();
21463
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 zinit = temp_zinit;
21464
21465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(zinit.heroAnimationStyle==las_zelda3slow)
21466 {
21467 hero_animation_speed=2;
21468 }
21469 else
21470 {
21471 480 hero_animation_speed=1;
21472 }
21473
21474 480 return 0;
21475 480 }
21476
21477 /*
21478 void setupitemdropsets()
21479 {
21480 for(int32_t i=0; i<isMAX; i++)
21481 {
21482 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21483 }
21484 }
21485 */
21486
21487 421 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21488 {
21489
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 23 times.
421 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21490
21491 dword dummy_dword;
21492 421 word item_drop_sets_to_read=0;
21493 item_drop_object tempitemdrop;
21494 421 word s_version=0;
21495
21496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if (!should_skip)
21497
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21498 {
21499 107776 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21500 108197 }
21501
21502
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 23 times.
421 if(version > 0x192)
21503 {
21504 398 item_drop_sets_to_read=0;
21505
21506 //section version info
21507
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&s_version,f))
21508 {
21509 return qe_invalid;
21510 }
21511
21512 398 FFCore.quest_format[vItemDropsets] = s_version;
21513
21514
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
21515 {
21516 return qe_invalid;
21517 }
21518
21519 //section size
21520
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy_dword,f))
21521 {
21522 return qe_invalid;
21523 }
21524
21525 //finally... section data
21526
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&item_drop_sets_to_read,f))
21527 {
21528 return qe_invalid;
21529 }
21530
21531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21532 {
21533 return qe_invalid;
21534 }
21535 398 }
21536 else
21537 {
21538 23 init_item_drop_sets();
21539 }
21540
21541
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 398 times.
421 if(s_version>=1)
21542 {
21543
2/2
✓ Branch 0 taken 6016 times.
✓ Branch 1 taken 398 times.
6414 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21544 {
21545
1/2
✓ Branch 0 taken 6016 times.
✗ Branch 1 not taken.
6016 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21546 {
21547 return qe_invalid;
21548 }
21549
21550
2/2
✓ Branch 0 taken 60160 times.
✓ Branch 1 taken 6016 times.
66176 for(int32_t j=0; j<10; ++j)
21551 {
21552
1/2
✓ Branch 0 taken 60160 times.
✗ Branch 1 not taken.
60160 if(!p_igetw(&tempitemdrop.item[j],f))
21553 {
21554 return qe_invalid;
21555 }
21556 60160 }
21557
21558
2/2
✓ Branch 0 taken 66176 times.
✓ Branch 1 taken 6016 times.
72192 for(int32_t j=0; j<11; ++j)
21559 {
21560
1/2
✓ Branch 0 taken 66176 times.
✗ Branch 1 not taken.
66176 if(!p_igetw(&tempitemdrop.chance[j],f))
21561 {
21562 return qe_invalid;
21563 }
21564 66176 }
21565
21566 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21567 // overrides the quest's set #12.
21568
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6016 if(s_version<2 && i==12)
21569 continue;
21570
21571 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21572
1/4
✓ Branch 0 taken 6016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6016 if(s_version<2) for(int32_t j=0; j<10; ++j)
21573 {
21574 int32_t it = tempitemdrop.item[j];
21575
21576 if((itemsbuf[it].type == itype_rupee
21577 && ((itemsbuf[it].amount)&0xFFF) == 10)
21578 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21579 {
21580 tempitemdrop.chance[j+1]=0;
21581 }
21582 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21583 {
21584 tempitemdrop.chance[j+1]=0;
21585 }
21586
21587 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21588 if(itemsbuf[it].type == itype_misc)
21589 {
21590 // If a non-gameplay item was selected, then item drop was aborted.
21591 // Reflect this by increasing the 'Nothing' chance accordingly.
21592 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21593 tempitemdrop.chance[j+1]=0;
21594 }
21595 }
21596
21597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6016 times.
6016 if (!should_skip)
21598 6016 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21599 6016 }
21600 398 }
21601
21602 421 return 0;
21603 421 }
21604
21605 398 int32_t readfavorites(PACKFILE *f, int32_t)
21606 {
21607
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21608
21609 int32_t temp_num;
21610 dword dummy_dword;
21611 word num_favorite_combos;
21612 word num_favorite_combo_aliases;
21613 398 word s_version=0;
21614
21615 //section version info
21616
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&s_version,f))
21617 {
21618 return qe_invalid;
21619 }
21620
21621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!should_skip)
21622 398 FFCore.quest_format[vFavourites] = s_version;
21623
21624
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
21625 {
21626 return qe_invalid;
21627 }
21628
21629 //section size
21630
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy_dword,f))
21631 {
21632 return qe_invalid;
21633 }
21634
21635 398 word per_row = FAVORITECOMBO_PER_ROW;
21636 398 word per_page = FAVORITECOMBO_PER_PAGE;
21637
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 187 times.
398 if(s_version >= 3)
21638
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(!p_igetw(&per_row,f))
21639 return qe_invalid;
21640
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version >= 4)
21641
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_igetw(&per_page,f))
21642 return qe_invalid;
21643 //finally... section data
21644
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&num_favorite_combos,f))
21645 {
21646 return qe_invalid;
21647 }
21648
21649 //Hack; port old favorite combos
21650
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 187 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
398 if(s_version < 3 && num_favorite_combos == 100)
21651 211 per_row = 13;
21652
21653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!should_skip)
21654
2/2
✓ Branch 0 taken 501480 times.
✓ Branch 1 taken 398 times.
501878 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21655 501878 favorite_combos[q] = -1;
21656 398 byte favtype = 0;
21657
2/2
✓ Branch 0 taken 27995 times.
✓ Branch 1 taken 398 times.
28393 for(int32_t i=0; i<num_favorite_combos; i++)
21658 {
21659
2/2
✓ Branch 0 taken 6889 times.
✓ Branch 1 taken 21106 times.
27995 if (s_version >= 4)
21660 {
21661
1/2
✓ Branch 0 taken 6889 times.
✗ Branch 1 not taken.
6889 if (!p_getc(&favtype, f))
21662 {
21663 return qe_invalid;
21664 }
21665 6889 }
21666 else
21667 21106 favtype = 0;
21668
1/2
✓ Branch 0 taken 27995 times.
✗ Branch 1 not taken.
27995 if(!p_igetl(&temp_num,f))
21669 {
21670 return qe_invalid;
21671 }
21672
21673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27995 times.
27995 if (should_skip)
21674 continue;
21675
21676
2/2
✓ Branch 0 taken 6889 times.
✓ Branch 1 taken 21106 times.
27995 if(per_row == FAVORITECOMBO_PER_ROW)
21677 {
21678 6889 favorite_combos[i] = temp_num;
21679 6889 favorite_combo_modes[i] = favtype;
21680 6889 }
21681 else
21682 {
21683 21106 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21684 21106 favorite_combos[new_i]=temp_num;
21685 21106 favorite_combo_modes[new_i] = favtype;
21686 }
21687 27995 }
21688
21689 // Discard the separate favorite aliases list from previous versions
21690
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 217 times.
398 if(s_version<4)
21691 {
21692
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (!p_igetw(&num_favorite_combo_aliases, f))
21693 {
21694 return qe_invalid;
21695 }
21696
21697
2/2
✓ Branch 0 taken 21100 times.
✓ Branch 1 taken 217 times.
21317 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21698 {
21699
1/2
✓ Branch 0 taken 21100 times.
✗ Branch 1 not taken.
21100 if (!p_igetl(&temp_num, f))
21700 {
21701 return qe_invalid;
21702 }
21703 21100 }
21704 217 }
21705
21706 398 word max_combo_cols = 0;
21707 398 word max_mappages = 0;
21708
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 187 times.
398 if(s_version >= 2)
21709 {
21710
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(!p_igetw(&max_combo_cols,f))
21711 return qe_invalid;
21712 187 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21713
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 187 times.
935 for(int q = 0; q < max_combo_cols; ++q)
21714 {
21715
1/2
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
748 if(!p_igetl(&tmp,f))
21716 return qe_invalid;
21717
1/2
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
748 if(!p_igetl(&tmp2,f))
21718 return qe_invalid;
21719
1/2
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
748 if(!p_igetl(&tmp3,f))
21720 return qe_invalid;
21721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
748 if(q < MAX_COMBO_COLS)
21722 {
21723 748 First[q] = tmp;
21724 748 combo_alistpos[q] = tmp2;
21725 748 combo_pool_listpos[q] = tmp3;
21726 748 }
21727 748 }
21728
21729
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(!p_igetw(&max_mappages,f))
21730 return qe_invalid;
21731
2/2
✓ Branch 0 taken 1683 times.
✓ Branch 1 taken 187 times.
1870 for(int q = 0; q < max_mappages; ++q)
21732 {
21733
1/2
✓ Branch 0 taken 1683 times.
✗ Branch 1 not taken.
1683 if(!p_igetl(&tmp,f))
21734 return qe_invalid;
21735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
1683 if(!p_igetl(&tmp2,f))
21736 return qe_invalid;
21737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
1683 if(q < MAX_MAPPAGE_BTNS)
21738 {
21739 1683 map_page[q].map = tmp;
21740 1683 map_page[q].screen = tmp2;
21741 1683 }
21742 1683 }
21743 187 }
21744
21745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (should_skip)
21746 return 0;
21747
21748
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 398 times.
1242 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21749 {
21750 844 First[q] = 0;
21751 844 combo_alistpos[q] = 0;
21752 844 combo_pool_listpos[q] = 0;
21753 844 }
21754
2/2
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 398 times.
2297 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21755 {
21756 1899 map_page[q].map = 0;
21757 1899 map_page[q].screen = 0;
21758 1899 }
21759
21760 398 return 0;
21761 398 }
21762
21763 /*
21764 switch (ret) {
21765 case 0:
21766 break;
21767
21768 case qe_invalid:
21769 goto invalid;
21770 break;
21771 default:
21772 pack_fclose(f);
21773 if(!oldquest)
21774 delete_file(tmpfilename);
21775 return ret;
21776 break;
21777 }
21778 */
21779
21780 const char *skip_text[skip_max]=
21781 {
21782 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21783 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21784 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21785 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21786 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21787 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21788 "skip_favorites"
21789 };
21790
21791
21792 void port250QuestRules(){
21793
21794 portCandleRules(); //Candle
21795 portBombRules();
21796
21797 }
21798
21799 void portCandleRules()
21800 {
21801 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21802 //itemdata itemsbuf;
21803 for ( int32_t q = 0; q < MAXITEMS; q++ )
21804 {
21805 if ( itemsbuf[q].type == itype_candle )
21806 {
21807 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21808 else itemsbuf[q].flags &= ~ item_flag2;
21809 }
21810 }
21811 }
21812
21813 void portBombRules()
21814 {
21815 bool hurtshero = get_qr(qr_OUCHBOMBS);
21816 //itemdata itemsbuf;
21817 for ( int32_t q = 0; q < MAXITEMS; q++ )
21818 {
21819 if ( itemsbuf[q].type == itype_bomb )
21820 {
21821 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21822 else itemsbuf[q].flags &= ~ item_flag2;
21823 }
21824 }
21825 }
21826
21827 18597 static int section_id_to_enum(int id)
21828 {
21829
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 804 times.
✓ Branch 3 taken 804 times.
✓ Branch 4 taken 804 times.
✓ Branch 5 taken 804 times.
✓ Branch 6 taken 721 times.
✓ Branch 7 taken 804 times.
✓ Branch 8 taken 804 times.
✓ Branch 9 taken 804 times.
✓ Branch 10 taken 804 times.
✓ Branch 11 taken 804 times.
✓ Branch 12 taken 804 times.
✓ Branch 13 taken 721 times.
✓ Branch 14 taken 721 times.
✓ Branch 15 taken 804 times.
✓ Branch 16 taken 804 times.
✓ Branch 17 taken 745 times.
✓ Branch 18 taken 721 times.
✓ Branch 19 taken 721 times.
✓ Branch 20 taken 721 times.
✓ Branch 21 taken 804 times.
✓ Branch 22 taken 804 times.
✓ Branch 23 taken 745 times.
✓ Branch 24 taken 721 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18597 switch (id)
21830 {
21831 case ID_HEADER: return skip_header;
21832 804 case ID_RULES: return skip_rules;
21833 804 case ID_STRINGS: return skip_strings;
21834 804 case ID_MISC: return skip_misc;
21835 804 case ID_TILES: return skip_tiles;
21836 804 case ID_COMBOS: return skip_combos;
21837 721 case ID_COMBOALIASES: return skip_comboaliases;
21838 804 case ID_CSETS: return skip_csets;
21839 804 case ID_MAPS: return skip_maps;
21840 804 case ID_DMAPS: return skip_dmaps;
21841 804 case ID_DOORS: return skip_doors;
21842 804 case ID_ITEMS: return skip_items;
21843 804 case ID_WEAPONS: return skip_weapons;
21844 721 case ID_COLORS: return skip_colors;
21845 721 case ID_ICONS: return skip_icons;
21846 804 case ID_INITDATA: return skip_initdata;
21847 804 case ID_GUYS: return skip_guys;
21848 745 case ID_HEROSPRITES: return skip_herosprites;
21849 721 case ID_SUBSCREEN: return skip_subscreens;
21850 721 case ID_FFSCRIPT: return skip_ffscript;
21851 721 case ID_SFX: return skip_sfx;
21852 804 case ID_MIDIS: return skip_midis;
21853 804 case ID_CHEATS: return skip_cheats;
21854 745 case ID_ITEMDROPSETS: return skip_itemdropsets;
21855 721 case ID_FAVORITES: return skip_favorites;
21856 case ID_ZINFO: return skip_zinfo;
21857 }
21858
21859 return -1;
21860 18597 }
21861
21862 18189 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21863 {
21864 18189 int section_enum = section_id_to_enum(section_id);
21865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18189 times.
18189 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21866
2/2
✓ Branch 0 taken 6783 times.
✓ Branch 1 taken 11406 times.
18189 if (skip)
21867 {
21868 word s_version;
21869
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!p_igetw(&s_version,f))
21870 {
21871 return qe_invalid;
21872 }
21873
21874
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!read_deprecated_section_cversion(f))
21875 {
21876 return qe_invalid;
21877 }
21878
21879
3/4
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
6783 if (section_id == ID_RULES && s_version > 16)
21880 {
21881 dword dummy;
21882 if (!p_igetl(&dummy,f))
21883 {
21884 return qe_invalid;
21885 }
21886 }
21887
21888
3/4
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
6783 if (section_id == ID_FFSCRIPT && s_version >= 18)
21889 {
21890 word dummy;
21891 if (!p_igetw(&dummy,f))
21892 {
21893 return qe_invalid;
21894 }
21895 }
21896
21897 dword section_length;
21898
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!p_igetl(&section_length,f))
21899 {
21900 return qe_invalid;
21901 }
21902
21903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6783 times.
6783 if (pack_fseek(f, section_length))
21904 {
21905 return qe_invalid;
21906 }
21907
21908
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
6783 if (!pack_feof(f))
21909 {
21910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6460 times.
6460 if (!p_mgetl(&section_id,f))
21911 {
21912 return qe_invalid;
21913 }
21914 6460 }
21915
21916 6783 return qe_cancel;
21917 }
21918
21919 11406 return qe_OK;
21920 18189 }
21921
21922 // TODO: this was copied from zc/zasm_utils.cpp
21923 282 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21924 {
21925 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21926
21927 282 std::vector<zasm_script*> scripts;
21928
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 scripts.reserve(zasm_scripts.size());
21929
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 301585 times.
301867 for (auto& script : zasm_scripts)
21930
2/2
✓ Branch 0 taken 293103 times.
✓ Branch 1 taken 8482 times.
301585 if (script->valid())
21931
1/2
✓ Branch 0 taken 8482 times.
✗ Branch 1 not taken.
8482 scripts.push_back(script.get());
21932
21933
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 282 times.
✗ Branch 3 not taken.
282 std::for_each(scripts.begin(), scripts.end(), fn);
21934 282 }
21935
21936 480 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21937 {
21938 // 2.55.9 or newer?
21939
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 326 times.
480 if (header.compareVer(2, 55, 9) >= 0)
21940 154 return false; // defer to whatever was set
21941
21942 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
21943
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 276 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 276 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 276 times.
✓ Branch 12 taken 38 times.
✓ Branch 13 taken 288 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
326 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
21944 38 return true;
21945
21946 // Quests prior to 2.55.9 with a scripted subscreen?
21947
2/2
✓ Branch 0 taken 145923 times.
✓ Branch 1 taken 285 times.
146208 for (int i = 0; i < MAXDMAPS; i++)
21948 {
21949 145923 int script = DMaps[i].active_sub_script;
21950
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 145920 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
145923 if (script && dmapscripts[script] && dmapscripts[script]->valid())
21951 3 return true;
21952 145920 }
21953
21954 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
21955
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 std::string title = header.title;
21956
3/4
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 282 times.
285 if (title == "Yuurand: Tales of the Labyrinth")
21957 3 return true;
21958
21959 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
21960 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
21961 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
21962 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
21963 282 bool found = false;
21964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
8764 _zasm_for_every_script([&](auto script){
21965
2/2
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 5449 times.
8482 if (found) return;
21966
21967
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 23840130 times.
23845549 for (const auto& instr : script->zasm)
21968 {
21969
4/4
✓ Branch 0 taken 20882211 times.
✓ Branch 1 taken 2957919 times.
✓ Branch 2 taken 358211 times.
✓ Branch 3 taken 20524000 times.
23840130 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
21970
21971 3316130 int value = instr.arg2;
21972
9/10
✓ Branch 0 taken 3316128 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3316125 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3316101 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3316101 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3316100 times.
3316130 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
21973 {
21974 30 found = true;
21975 30 break;
21976 }
21977 }
21978 8482 });
21979
21980 282 return found;
21981 480 }
21982
21983 static int32_t prev_quest_format[versiontypesLAST];
21984 static byte prev_quest_rules[QUESTRULES_NEW_SIZE];
21985 static byte prev_extra_rules[EXTRARULES_SIZE];
21986 static byte prev_midi_flags[MIDIFLAGS_SIZE];
21987 static word prev_map_count;
21988
21989 // When skipping any section, we are loading a qst file just to poke at a couple things.
21990 // We should not mutate important globals in that case.
21991 // We should also restore these globals when loading a qst fails.
21992 // Globals that are read by usecases of `skip_flags` will have to be restored manually by the caller
21993 // (see load_imagebuf).
21994 804 static void store_prev_qstload_global_state()
21995 {
21996 804 memcpy(prev_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21997 804 memcpy(prev_extra_rules, extra_rules, EXTRARULES_SIZE);
21998 804 memcpy(prev_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21999 804 memcpy(prev_quest_format, FFCore.quest_format, versiontypesLAST);
22000 804 prev_map_count = map_count;
22001 804 }
22002
22003 324 static void restore_prev_qstload_global_state()
22004 {
22005 324 memcpy(quest_rules, prev_quest_rules, QUESTRULES_NEW_SIZE);
22006 324 memcpy(extra_rules, prev_extra_rules, EXTRARULES_SIZE);
22007 324 unpack_qrs();
22008 324 memcpy(midi_flags, prev_midi_flags, MIDIFLAGS_SIZE);
22009 324 memcpy(FFCore.quest_format, prev_quest_format, versiontypesLAST);
22010 324 map_count = prev_map_count;
22011 324 }
22012
22013 //Internal function for loadquest wrapper
22014 // TODO: refactor to never mutate global state, to make loading partial qst files easier and less error prone. huge project.
22015 804 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
22016 {
22017 804 DMapEditorLastMaptileUsed = 0;
22018 804 combosread=false;
22019 804 mapsread=false;
22020 804 fixffcs=false;
22021
22022 804 store_prev_qstload_global_state();
22023
22024 804 bool skipping_any = false;
22025
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 804 times.
4020 for (int i = 0; i < 4; i++)
22026 3216 skipping_any |= skip_flags[i] ? true : false;
22027
22028 804 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
22029
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
22030 {
22031 set_bit(skip_flags, skip_ffscript, 1);
22032 setZScriptVersion(V_FFSCRIPT);
22033 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
22034 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
22035 do_clear_scripts = true;
22036 }
22037
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(loading_tileset_flags & TILESET_CLEARMAPS)
22038 {
22039 set_bit(skip_flags, skip_maps, 1);
22040 }
22041
22042 char tmpfilename[L_tmpnam];
22043 804 temp_name(tmpfilename);
22044 804 bool catchup=false;
22045 byte tempbyte;
22046
22047 // oldquest flag is set when an unencrypted qst file is suspected.
22048 804 bool oldquest = false;
22049 804 int32_t open_error=0;
22050 804 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
22051
22052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (!f)
22053 {
22054 ASSERT(open_error != 0);
22055 return open_error;
22056 }
22057
22058 804 memset(quest_rules, 0, QUESTRULES_NEW_SIZE);
22059 804 memset(extra_rules, 0, EXTRARULES_SIZE);
22060 804 unpack_qrs();
22061
22062
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if (!get_bit(skip_flags, skip_maps))
22063 480 Regions = {};
22064
22065
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if(do_clear_scripts)
22066 {
22067 480 zScript.clear();
22068 480 globalmap.clear();
22069 480 genericmap.clear();
22070 480 ffcmap.clear();
22071 480 itemmap.clear();
22072 480 npcmap.clear();
22073 480 ewpnmap.clear();
22074 480 lwpnmap.clear();
22075 480 playermap.clear();
22076 480 dmapmap.clear();
22077 480 screenmap.clear();
22078 480 itemspritemap.clear();
22079 480 comboscriptmap.clear();
22080 480 subscreenmap.clear();
22081
22082
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
22083 {
22084 245280 ffcmap[i].clear();
22085 245280 }
22086
22087 480 globalmap[0].slotname = "Slot 1:";
22088 480 globalmap[0].scriptname = "~Init";
22089 480 globalmap[0].update();
22090
22091
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 480 times.
3840 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
22092 {
22093 3360 globalmap[i].clear();
22094 3360 }
22095
22096
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
22097 {
22098 122400 itemmap[i].clear();
22099 122400 }
22100
22101 //new script types -- prevent carrying over to a quest that you load after reading them
22102 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
22103
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
22104 {
22105 122400 npcmap[i].clear();
22106 122400 }
22107
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22108 {
22109 122400 lwpnmap[i].clear();
22110 122400 }
22111
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22112 {
22113 122400 ewpnmap[i].clear();
22114 122400 }
22115
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 480 times.
2400 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
22116 {
22117 1920 playermap[i].clear();
22118 1920 }
22119
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
22120 {
22121 122400 dmapmap[i].clear();
22122 122400 }
22123
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
22124 {
22125 122400 screenmap[i].clear();
22126 122400 }
22127
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
22128 {
22129 122400 itemspritemap[i].clear();
22130 122400 }
22131
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
22132 {
22133 245280 comboscriptmap[i].clear();
22134 245280 }
22135
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
22136 {
22137 245280 genericmap[i].clear();
22138 245280 }
22139
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
22140 {
22141 122400 subscreenmap[i].clear();
22142 122400 }
22143
22144 480 reset_scripts();
22145 480 }
22146
22147 804 zquestheader tempheader{};
22148
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tempheader.filename = filename;
22149
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 zinfo tempzi;
22150
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tempzi.clear();
22151 804 load_tmp_zi = &tempzi;
22152
22153 char zinfofilename[2048];
22154
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 replace_extension(zinfofilename, filename, "zinfo", 2047);
22155 804 int32_t ret=0;
22156
22157 //header
22158
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("Reading Header...");
22159
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 ret=readheader(f, &tempheader, printmetadata);
22160
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
804 checkstatus(ret);
22161
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("okay.");
22162
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_eol();
22163
22164
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
804 if(read_zinfo)
22165 {
22166
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 box_out("Reading ZInfo - ");
22167
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 box_out(read_ext_zinfo ? "External..." : "Internal...");
22168
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 195 times.
198 if(read_ext_zinfo)
22169 {
22170
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
22171
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
22172
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
22173
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
22174 3 }
22175 else
22176 {
22177
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 ret=readzinfo(f, tempzi, tempheader);
22178
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
195 checkstatus(ret);
22179 }
22180
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 box_out("okay.");
22181
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 box_eol();
22182 198 }
22183
22184
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(tempheader.zelda_version>=0x193)
22185 {
22186 dword section_id;
22187
22188 //section id
22189
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_mgetl(&section_id,f))
22190 {
22191 goto invalid;
22192 }
22193
22194 780 std::set<dword> seen_sections;
22195
22196
3/4
✓ Branch 0 taken 18969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18189 times.
✓ Branch 3 taken 780 times.
18969 while(!pack_feof(f))
22197 {
22198
2/4
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18189 times.
✗ Branch 3 not taken.
18189 if (seen_sections.contains(section_id))
22199 goto invalid;
22200
1/2
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
18189 seen_sections.insert(section_id);
22201
22202
3/4
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11406 times.
✓ Branch 3 taken 6783 times.
18189 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22203 {
22204
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (retval == qe_cancel)
22205 6783 continue;
22206 checkstatus(retval);
22207 }
22208
22209
24/25
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 457 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 780 times.
✓ Branch 4 taken 457 times.
✓ Branch 5 taken 398 times.
✓ Branch 6 taken 780 times.
✓ Branch 7 taken 457 times.
✓ Branch 8 taken 457 times.
✓ Branch 9 taken 457 times.
✓ Branch 10 taken 457 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 398 times.
✓ Branch 13 taken 398 times.
✓ Branch 14 taken 457 times.
✓ Branch 15 taken 457 times.
✓ Branch 16 taken 398 times.
✓ Branch 17 taken 398 times.
✓ Branch 18 taken 398 times.
✓ Branch 19 taken 398 times.
✓ Branch 20 taken 457 times.
✓ Branch 21 taken 457 times.
✓ Branch 22 taken 398 times.
✓ Branch 23 taken 398 times.
✗ Branch 24 not taken.
11406 switch(section_id)
22210 {
22211 case ID_RULES:
22212
22213 //rules
22214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22215 {
22216 box_out("found.");
22217 box_eol();
22218 catchup=false;
22219 }
22220
22221
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Rules...");
22222
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readrules(f, &tempheader);
22223
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22224
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22225
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22226 457 break;
22227
22228 case ID_STRINGS:
22229
22230 //strings
22231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22232 {
22233 box_out("found.");
22234 box_eol();
22235 catchup=false;
22236 }
22237
22238
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Strings...");
22239
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readstrings(f, &tempheader);
22240
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22241
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22242
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22243 457 break;
22244
22245 case ID_MISC:
22246
22247 //misc data
22248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22249 {
22250 box_out("found.");
22251 box_eol();
22252 catchup=false;
22253 }
22254
22255
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Misc. Data...");
22256
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readmisc(f, &tempheader, Misc);
22257
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22258
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22259
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22260 780 break;
22261
22262 case ID_TILES:
22263
22264 //tiles
22265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22266 {
22267 box_out("found.");
22268 box_eol();
22269 catchup=false;
22270 }
22271
22272
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Tiles...");
22273
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
22274
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22275
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22276
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22277 780 break;
22278
22279 case ID_COMBOS:
22280
22281 //combos
22282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22283 {
22284 box_out("found.");
22285 box_eol();
22286 catchup=false;
22287 }
22288
22289
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Combos...");
22290
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
22291 457 combosread=true;
22292
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22293
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22294
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22295 457 break;
22296
22297 case ID_COMBOALIASES:
22298
22299 //combo aliases
22300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22301 {
22302 box_out("found.");
22303 box_eol();
22304 catchup=false;
22305 }
22306
22307
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Combo Aliases...");
22308
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
22309
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22310
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22311
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22312 398 break;
22313
22314 case ID_CSETS:
22315
22316 //color data
22317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22318 {
22319 box_out("found.");
22320 box_eol();
22321 catchup=false;
22322 }
22323
22324
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Color Data...");
22325
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
22326
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22327
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22328
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22329 780 break;
22330
22331 case ID_MAPS:
22332
22333 //maps
22334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22335 {
22336 box_out("found.");
22337 box_eol();
22338 catchup=false;
22339 }
22340
22341
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Maps...");
22342
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readmaps(f, &tempheader);
22343 457 mapsread=true;
22344
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22345
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22346
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22347 457 break;
22348
22349 case ID_DMAPS:
22350
22351 //dmaps
22352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22353 {
22354 box_out("found.");
22355 box_eol();
22356 catchup=false;
22357 }
22358
22359
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading DMaps...");
22360
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22361
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22362
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22363
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22364 457 break;
22365
22366 case ID_DOORS:
22367
22368 //door combo sets
22369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22370 {
22371 box_out("found.");
22372 box_eol();
22373 catchup=false;
22374 }
22375
22376
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Doors...");
22377
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readdoorcombosets(f, &tempheader);
22378
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22379
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22380
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22381 457 break;
22382
22383 case ID_ITEMS:
22384
22385 //items
22386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22387 {
22388 box_out("found.");
22389 box_eol();
22390 catchup=false;
22391 }
22392
22393
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Items...");
22394
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22395
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22396
22397
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22398
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22399 457 break;
22400
22401 case ID_WEAPONS:
22402
22403 //weapons
22404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22405 {
22406 box_out("found.");
22407 box_eol();
22408 catchup=false;
22409 }
22410
22411
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Weapons...");
22412
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readweapons(f, &tempheader);
22413
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22414
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22415
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22416 457 break;
22417
22418 case ID_COLORS:
22419
22420 //misc. colors
22421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22422 {
22423 box_out("found.");
22424 box_eol();
22425 catchup=false;
22426 }
22427
22428
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Misc. Colors...");
22429
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readmisccolors(f, &tempheader, Misc);
22430
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22431
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22432
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22433 398 break;
22434
22435 case ID_ICONS:
22436
22437 //game icons
22438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22439 {
22440 box_out("found.");
22441 box_eol();
22442 catchup=false;
22443 }
22444
22445
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Game Icons...");
22446
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readgameicons(f, &tempheader, Misc);
22447
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22448
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22449
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22450 398 break;
22451
22452 case ID_INITDATA:
22453
22454 //initialization data
22455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22456 {
22457 box_out("found.");
22458 box_eol();
22459 catchup=false;
22460 }
22461
22462
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Init. Data...");
22463
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readinitdata(f, &tempheader);
22464
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22465
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22466
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22467
22468
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
457 if(!get_bit(skip_flags, skip_subscreens))
22469 {
22470
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 363 times.
457 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22471 {
22472
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 setupsubscreens();
22473
22474
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<MAXDMAPS; ++i)
22475 {
22476 48128 int32_t type=DMaps[i].type&dmfTYPE;
22477
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 47042 times.
48128 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22478 48128 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22479 48128 }
22480 94 }
22481 457 }
22482
22483
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!get_bit(skip_flags, skip_sfx))
22484 {
22485 457 setupsfx();
22486 457 }
22487
22488
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!get_bit(skip_flags, skip_itemdropsets))
22489 {
22490
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 init_item_drop_sets();
22491 457 }
22492
22493
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
457 if(!get_bit(skip_flags, skip_favorites))
22494 {
22495 457 init_favorites();
22496 457 }
22497
22498 457 break;
22499
22500 case ID_GUYS:
22501
22502 //guys
22503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22504 {
22505 box_out("found.");
22506 box_eol();
22507 catchup=false;
22508 }
22509
22510
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Custom Guy Data...");
22511
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readguys(f, &tempheader);
22512
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22513
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22514
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22515 457 break;
22516
22517 case ID_HEROSPRITES:
22518
22519 //hero sprites
22520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22521 {
22522 box_out("found.");
22523 box_eol();
22524 catchup=false;
22525 }
22526
22527
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Custom Hero Sprite Data...");
22528
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readherosprites(f, &tempheader);
22529
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22530
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22531
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22532 398 break;
22533
22534 case ID_SUBSCREEN:
22535
22536 //custom subscreens
22537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22538 {
22539 box_out("found.");
22540 box_eol();
22541 catchup=false;
22542 }
22543
22544
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Custom Subscreen Data...");
22545
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readsubscreens(f);
22546
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22547
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22548
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22549 398 break;
22550
22551 case ID_FFSCRIPT:
22552
22553 //Freeform combo scripts
22554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22555 {
22556 box_out("found.");
22557 box_eol();
22558 catchup=false;
22559 }
22560
22561
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading FF Script Data...");
22562
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readffscript(f, &tempheader);
22563
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22564
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22565
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22566 398 break;
22567
22568 case ID_SFX:
22569
22570 //SFX data
22571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22572 {
22573 box_out("found.");
22574 box_eol();
22575 catchup=false;
22576 }
22577
22578
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading SFX Data...");
22579
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readsfx(f, &tempheader);
22580
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22581
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22582
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22583 398 break;
22584
22585 case ID_MIDIS:
22586
22587 //midis
22588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22589 {
22590 box_out("found.");
22591 box_eol();
22592 catchup=false;
22593 }
22594
22595
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Tunes...");
22596
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readtunes(f, &tempheader, tunes);
22597
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22598
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22599
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22600 457 break;
22601
22602 case ID_CHEATS:
22603
22604 //cheat codes
22605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22606 {
22607 box_out("found.");
22608 box_eol();
22609 catchup=false;
22610 }
22611
22612
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Cheat Codes...");
22613
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readcheatcodes(f, &tempheader);
22614
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22615
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22616
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22617 457 break;
22618
22619 case ID_ITEMDROPSETS:
22620
22621 //item drop sets
22622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22623 {
22624 box_out("found.");
22625 box_eol();
22626 catchup=false;
22627 }
22628
22629
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Item Drop Sets...");
22630
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readitemdropsets(f, tempheader.zelda_version);
22631
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22632
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22633
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22634 398 break;
22635
22636 case ID_FAVORITES:
22637
22638 //favorite combos and combo aliases
22639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22640 {
22641 box_out("found.");
22642 box_eol();
22643 catchup=false;
22644 }
22645
22646
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Favorite Combos...");
22647
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readfavorites(f, tempheader.zelda_version);
22648
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22649
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22650
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22651 398 break;
22652
22653 default:
22654 if(!catchup)
22655 {
22656 box_out("Bad token! Searching...");
22657 box_eol();
22658 }
22659
22660 catchup=true;
22661 break;
22662 }
22663
22664
22665
1/2
✓ Branch 0 taken 11406 times.
✗ Branch 1 not taken.
11406 if(catchup)
22666 {
22667 //section id
22668 section_id=(section_id<<8);
22669
22670 if(!p_getc(&tempbyte,f))
22671 {
22672 goto invalid;
22673 }
22674
22675 section_id+=tempbyte;
22676 }
22677
22678 else
22679 {
22680 //section id
22681
3/4
✓ Branch 0 taken 11406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10949 times.
✓ Branch 3 taken 457 times.
11406 if(!pack_feof(f))
22682 {
22683
2/4
✓ Branch 0 taken 10949 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10949 times.
✗ Branch 3 not taken.
10949 if(!p_mgetl(&section_id,f))
22684 {
22685 goto invalid;
22686 }
22687 10949 }
22688 }
22689 }
22690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 }
22691 else
22692 {
22693
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22694
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22695
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22696
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22697
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22698
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22699
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22700
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22701
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22702
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22703
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22704
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22705
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22706
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22707
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22708
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22709
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22710
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22711 };
22712
22713 24 legacy_skip_flags = skip_flags;
22714
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22715 {
22716
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22717
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22718
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22719 {
22720 // Nothing to read.
22721
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22722 1 continue;
22723
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22724 1 continue;
22725
22726 // Haven't looked at how to skip these, because we don't need to currently: the only
22727 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22728
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22729 1 continue;
22730
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22731 1 continue;
22732
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22733 1 continue;
22734
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22735 1 continue;
22736
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22737 1 continue;
22738 9 }
22739
22740 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22741 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22742 // read all the sections even if requested to skip some.
22743 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22744 // {
22745 // if (retval == qe_cancel)
22746 // continue;
22747 // checkstatus(retval);
22748 // }
22749
22750
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22751
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22752
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22753
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22754
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22755 }
22756 24 legacy_skip_flags = nullptr;
22757
22758
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22759 {
22760
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22761
22762
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22763 {
22764 11776 int32_t type=DMaps[i].type&dmfTYPE;
22765
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22766 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22767 11776 }
22768 23 }
22769
22770
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22771
22772
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22773 23 setupsfx();
22774
22775
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22776 23 init_favorites();
22777
22778
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22779
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22780
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22781
22782
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 init_spritelists();
22783
22784 // check data
22785
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(f)
22786 {
22787
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 pack_fclose(f);
22788 804 }
22789
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 clear_quest_tmpfile();
22790
22791
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(!oldquest)
22792 {
22793
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
804 if(exists(tmpfilename))
22794 {
22795 delete_file(tmpfilename);
22796 }
22797 804 }
22798
22799
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if(fixffcs && combosread && mapsread)
22800 {
22801 for(int32_t i=0; i<map_count; i++)
22802 {
22803 for(int32_t j=0; j<MAPSCRS; j++)
22804 {
22805 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22806 for(int32_t m=0; m<c; m++)
22807 {
22808 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22809 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22810 }
22811 }
22812 }
22813 }
22814
22815
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if (!get_bit(skip_flags, skip_rules))
22816 {
22817
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22818
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22819
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 406 times.
480 if (should_hide)
22820
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22821
22822
3/4
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 345 times.
480 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22823 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22824 480 }
22825
22826
7/10
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 741 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
804 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22827 {
22828
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 set_qr(qr_CONTFULL_DEP, 0);
22829
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22830 62 zinit.cont_heart=100;
22831 62 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22832 62 }
22833
22834
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("Done.");
22835
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_eol();
22836
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_end(false);
22837
22838
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 481 times.
✓ Branch 3 taken 323 times.
804 if(!get_bit(skip_flags, skip_header))
22839 {
22840
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 *Header = tempheader;
22841 481 }
22842
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if(!get_bit(skip_flags, skip_zinfo))
22843 {
22844
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 ZI.copyFrom(tempzi);
22845 480 }
22846
22847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(loading_tileset_flags & TILESET_CLEARMAPS)
22848 {
22849 TheMaps.clear();
22850 TheMaps.resize(MAPSCRS*1);
22851 map_count = 1;
22852 map_infos.clear();
22853 map_infos.resize(1);
22854 }
22855
22856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(loading_tileset_flags & TILESET_CLEARHEADER)
22857 {
22858 memset(Header->password, 0, sizeof(Header->password));
22859 memset(Header->minver, 0, sizeof(Header->minver));
22860 memset(Header->title, 0, sizeof(Header->title));
22861 memset(Header->author, 0, sizeof(Header->author));
22862 memset(Header->version, 0, sizeof(Header->version));
22863 Header->use_keyfile = 0;
22864 Header->dirty_password = false;
22865 cvs_MD5Context ctx;
22866 cvs_MD5Init(&ctx);
22867 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22868 cvs_MD5Final(Header->pwd_hash, &ctx);
22869 }
22870
22871
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if (!get_bit(skip_flags, skip_maps))
22872 {
22873 // Not needed, so release its memory.
22874
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 old_combo_pages = {};
22875 480 }
22876
22877
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if (skipping_any)
22878
1/2
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
324 restore_prev_qstload_global_state();
22879
22880 804 return qe_OK;
22881
22882 invalid:
22883 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22884 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22885 box_out("error.");
22886 box_eol();
22887 box_end(true);
22888
22889 pack_fclose(f);
22890
22891 if(!oldquest)
22892 {
22893 if(exists(tmpfilename))
22894 {
22895 delete_file(tmpfilename);
22896 }
22897 }
22898
22899 restore_prev_qstload_global_state();
22900
22901 return qe_invalid;
22902
22903 804 }
22904
22905 static bool _is_loading_quest;
22906
22907 bool is_loading_quest()
22908 {
22909 return _is_loading_quest;
22910 }
22911
22912 323 std::string get_last_loaded_qstpath()
22913 {
22914 323 return last_loaded_qstpath;
22915 }
22916
22917 804 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22918 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22919 bool report, byte qst_num, dword tilesetflags)
22920 {
22921 804 loading_tileset_flags = tilesetflags;
22922 804 const char* basename = get_filename(filename);
22923 804 zapp_reporting_add_breadcrumb("load_quest", basename);
22924 804 zapp_reporting_set_tag("qst.filename", basename);
22925
22926 804 last_loaded_qstpath = filename;
22927 804 loading_qst_name = filename;
22928 804 loading_qst_num = qst_num;
22929 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22930 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22931
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (!is_ci())
22932 loadquest_report = report;
22933
22934 804 _is_loading_quest = true;
22935 804 auto start = std::chrono::steady_clock::now();
22936 804 zprint2("Loading qst: %s\n", filename);
22937 804 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22938 804 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22939 804 zprint2("Time to load qst: %d ms\n", load_ms);
22940 804 _is_loading_quest = false;
22941
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (ret)
22942 zprint2("Error: %s\n", qst_error[ret]);
22943
22944
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(show_progress)
22945 {
22946 if(ret)
22947 {
22948 box_out("-- Error loading quest file! --");
22949 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
22950 box_end(true);
22951 }
22952 else box_end(false);
22953 }
22954
22955 804 load_tmp_zi = NULL;
22956 804 loading_qst_name = NULL;
22957 804 loadquest_report = false;
22958 804 loading_qst_num = 0;
22959
22960 804 zapp_reporting_set_tag("qst.author", Header->author);
22961 804 zapp_reporting_set_tag("qst.title", Header->title);
22962 804 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22963
22964 804 return ret;
22965 }
22966